Queries animation frame count (returns calculated frameCount from b2dLoadAnimImage).
Takes imageHandle (image handle from b2dLoadAnimImage, positive integer).
Returns frame count (positive integer, 0 if invalid or not animation).
2D Overlay
Parameters & Returns
Parameters
imageHandleInt
Returns
Int
Quick Summary
Queries animation frame count (returns calculated frameCount from b2dLoadAnimImage).
Takes imageHandle (image handle from b2dLoadAnimImage, positive integer).
Returns frame count (positive integer, 0 if invalid or not animation).
Technical Exegesis...
Queries animation frame count (returns calculated frameCount from b2dLoadAnimImage). Takes imageHandle (image handle from b2dLoadAnimImage, positive integer). Returns frame count (positive integer, 0 if invalid or not animation). Reads image.frameCount from g_images map (calculated as framesX x framesY during load). Use to query frame count (animation loop bounds, validate frame indices), iterate frames (loop through all frames), or check animation (determine if image is animation sheet).
Queries animation frame count (returns calculated frameCount from b2dLoadAnimImage). Takes imageHandle (image handle from b2dLoadAnimImage, positive integer). Returns frame count (positive integer, 0 if invalid or not animation). Reads image.frameCount from g_images map (calculated as framesX x framesY during load). Use to query frame count (animation loop bounds, validate frame indices), iterate frames (loop through all frames), or check animation (determine if image is animation sheet). Return behavior: returns frameCount if animation (positive integer, calculated during b2dLoadAnimImage), returns 0 if not animation (image loaded with b2dLoadImage, frameCount not set), returns 0 if invalid (handle not found in g_images map). Use cases: (1) Animation loop (For frame = 0 To b2dGetAnimFrameAmount(img)-1: draw frame Next), (2) Validate frame (If frame < b2dGetAnimFrameAmount(img) Then draw valid frame), (3) Random frame (frame = Rnd(b2dGetAnimFrameAmount(img)): select random), (4) Check animation (If b2dGetAnimFrameAmount(img) > 0 Then is animation sheet). Common patterns: query = count = b2dGetAnimFrameAmount(img): loop frames; validate = If frame < count Then draw. Frame calculation: framesX = width / frameWidth (horizontal frames), framesY = height / frameHeight (vertical frames), frameCount = framesX x framesY (total frames in grid). Example (256x128 sheet with 64x64 frames, framesX=4, framesY=2, returns 8 frames). Performance: query cost zero (map lookup and integer read, trivial CPU operation), safe to call every frame (no GPU cost, read-only operation). Related: b2dLoadAnimImage loads animation sheet (calculates frameCount returned by this function), b2dDrawAnimImage draws animation frame (uses frame index from 0 to frameCount-1), b2dGetImageWidth queries sheet width (full width, not frame width), b2dGetImageHeight queries sheet height (full height, not frame height).