Queues animation frame draw (selects frame from sprite sheet, applies current state).
Takes imageHandle (animation image handle from b2dLoadAnimImage, positive integer), x (screen X position in pixels, integer), y (screen Y position in pixels, integer), frame (frame index 0-based, integer, 0=first frame).
Returns nothing.
2D Overlay
Parameters & Returns
Parameters
imageHandleInt
xInt
yInt
frameInt
Returns
Void
Quick Summary
Queues animation frame draw (selects frame from sprite sheet, applies current state).
Takes imageHandle (animation image handle from b2dLoadAnimImage, positive integer), x (screen X position in pixels, integer), y (screen Y position in pixels, integer), frame (frame index 0-based, integer, 0=first frame).
Returns nothing.
Technical Exegesis...
Queues animation frame draw (selects frame from sprite sheet, applies current state). Takes imageHandle (animation image handle from b2dLoadAnimImage, positive integer), x (screen X position in pixels, integer), y (screen Y position in pixels, integer), frame (frame index 0-based, integer, 0=first frame). Returns nothing.
Queues animation frame draw (selects frame from sprite sheet, applies current state). Takes imageHandle (animation image handle from b2dLoadAnimImage, positive integer), x (screen X position in pixels, integer), y (screen Y position in pixels, integer), frame (frame index 0-based, integer, 0=first frame). Returns nothing. Calculates frame UV coordinates (frameX = frame % framesPerRow, frameY = frame / framesPerRow, UV rect from frameWidthxframeHeight grid), creates draw command (CMD_DRAW_ANIM_IMAGE type, stores frame index and state), queues to command buffer (executed during b3dRenderWorld). Use to draw animation frames (character walk cycle, explosions, UI states), draw tiles from tileset (select tile by index), or draw sprite from atlas (multi-sprite sheet). Frame selection: 0-indexed (frame 0=first frame top-left, frame 1=second frame, etc), row-major order (fills rows left-to-right before moving down), grid layout (frames arranged in regular grid frameWidthxframeHeight), calculates UV (determines texture coordinates for selected frame automatically). Use cases: (1) Character animation (b2dDrawAnimImage(walk, x, y, walkFrame): animate walk cycle), (2) Explosion (b2dDrawAnimImage(explode, x, y, explosionFrame): play explosion), (3) Tile drawing (b2dDrawAnimImage(tileset, tileX, tileY, tileIndex): draw tile from set), (4) UI states (b2dDrawAnimImage(button, x, y, state): 0=normal, 1=hover, 2=pressed), (5) Sprite atlas (b2dDrawAnimImage(atlas, x, y, spriteID): select sprite by ID). Common patterns: animate = frame = (frame + 1) Mod b2dGetAnimFrameAmount(img): b2dDrawAnimImage(img, x, y, frame) cycle frames; tile = b2dDrawAnimImage(tileset, x, y, tileID) draw specific tile. Frame bounds: valid range 0 to frameCount-1 (use b2dGetAnimFrameAmount to query max), out-of-bounds wraps (frame % frameCount, negative frames may cause issues), no validation (user responsible for valid frame index). UV calculation example: 256x128 sheet with 64x64 frames (framesX=4, framesY=2), frame 5 (frameX=5%4=1, frameY=5/4=1, UV rect = 64,64 to 128,128). State application: same as b2dDrawImage (color tint, alpha blend, scale, rotation from g_currentState), position top-left (x,y specify top-left corner of frame), transforms from center (scale/rotation around frame center). Performance: same cost as b2dDrawImage (additional UV calculation minimal, ~0.001ms per draw), GPU renders single frame (only selected frame drawn, not entire sheet). Related: b2dDrawAnimImageEx extended version (with per-draw shader parameter), b2dLoadAnimImage loads sprite sheet (creates animation image with frame data), b2dGetAnimFrameAmount queries frame count (returns max frames for bounds checking), b2dDrawImage draws normal image (no frame selection, draws entire image), b2dSetColor sets draw color (tints animation frame), b2dSetAlpha sets transparency (blends animation frame).