Loads animation sprite sheet (calculates frame count from dimensions, use with b2dDrawAnimImage).
Takes filePath (sprite sheet file path, string), frameWidth (width of single frame in pixels, integer), frameHeight (height of single frame in pixels, integer).
Returns image handle (positive integer, 0 on failure).
2D Overlay
Parameters & Returns
Parameters
filePathString
frameWidthInt
frameHeightInt
Returns
Int
Quick Summary
Loads animation sprite sheet (calculates frame count from dimensions, use with b2dDrawAnimImage).
Takes filePath (sprite sheet file path, string), frameWidth (width of single frame in pixels, integer), frameHeight (height of single frame in pixels, integer).
Returns image handle (positive integer, 0 on failure).
Technical Exegesis...
Loads animation sprite sheet (calculates frame count from dimensions, use with b2dDrawAnimImage). Takes filePath (sprite sheet file path, string), frameWidth (width of single frame in pixels, integer), frameHeight (height of single frame in pixels, integer). Returns image handle (positive integer, 0 on failure).
Loads animation sprite sheet (calculates frame count from dimensions, use with b2dDrawAnimImage). Takes filePath (sprite sheet file path, string), frameWidth (width of single frame in pixels, integer), frameHeight (height of single frame in pixels, integer). Returns image handle (positive integer, 0 on failure). Calls b2dLoadImage internally (loads full sprite sheet as single texture), calculates frame count (framesX = width / frameWidth, framesY = height / frameHeight, frameCount = framesX x framesY), stores frame dimensions (frameWidth/Height in OverlayImage structure). Use for sprite animation (character walk cycles, explosions, UI animations), tile sets (multiple tiles in grid), or sprite atlases (multiple sprites in single texture). Frame layout: grid arrangement (frames arranged left-to-right, top-to-bottom), equal-sized frames (all frames must be same widthxheight, no padding), 0-indexed (frame 0=top-left, frame 1=second from left, etc), row-major order (fills rows left-to-right before moving to next row). Calculation example: 256x128 sheet with 64x64 frames (framesX = 256/64 = 4, framesY = 128/64 = 2, frameCount = 4x2 = 8 frames total). Use cases: (1) Character animation (sheet = b2dLoadAnimImage("walk.png", 64, 64): 8-frame walk cycle), (2) Explosion (explosion = b2dLoadAnimImage("explode.png", 128, 128): multi-frame explosion), (3) Tile set (tiles = b2dLoadAnimImage("tiles.png", 32, 32): multiple terrain tiles), (4) UI animation (button = b2dLoadAnimImage("button.png", 100, 50): hover/pressed states), (5) Sprite atlas (sprites = b2dLoadAnimImage("atlas.png", 64, 64): multiple character sprites). Common patterns: load = img = b2dLoadAnimImage("sheet.png", frameW, frameH): calculate frame count; draw = b2dDrawAnimImage(img, x, y, frame): draw specific frame. Frame dimensions: must divide evenly (sheet width % frameWidth must = 0, sheet height % frameHeight must = 0), all frames same size (no variable-sized frames, must be uniform grid), padding not supported (frames must be adjacent, no spacing between). Performance: same as b2dLoadImage (just adds frame calculation, no extra GPU cost), frame count stored (calculated once at load, used by b2dDrawAnimImage). Related: b2dLoadImage loads normal image (no frame data, single static image), b2dDrawAnimImage draws animation frame (selects frame from sheet by index), b2dGetAnimFrameAmount queries frame count (returns calculated frameCount), b2dFreeImage frees animation sheet (releases texture and frame data), b2dGetImageWidth queries full sheet width (not frame width), b2dGetImageHeight queries full sheet height (not frame height).