Queries image width in pixels (returns full texture width, not frame width for anim images).
Takes imageHandle (image handle from b2dLoadImage/b2dLoadAnimImage, positive integer).
Returns width in pixels (positive integer, 0 if handle invalid).
2D Overlay
Parameters & Returns
Parameters
imageHandleInt
Returns
Int
Quick Summary
Queries image width in pixels (returns full texture width, not frame width for anim images).
Takes imageHandle (image handle from b2dLoadImage/b2dLoadAnimImage, positive integer).
Returns width in pixels (positive integer, 0 if handle invalid).
Technical Exegesis...
Queries image width in pixels (returns full texture width, not frame width for anim images). Takes imageHandle (image handle from b2dLoadImage/b2dLoadAnimImage, positive integer). Returns width in pixels (positive integer, 0 if handle invalid). Reads image.width from g_images map (original texture dimensions from file). Use to query dimensions (layout calculations, collision detection, scaling), center images (calculate position offset), or validate sizes (check image loaded correctly).
Queries image width in pixels (returns full texture width, not frame width for anim images). Takes imageHandle (image handle from b2dLoadImage/b2dLoadAnimImage, positive integer). Returns width in pixels (positive integer, 0 if handle invalid). Reads image.width from g_images map (original texture dimensions from file). Use to query dimensions (layout calculations, collision detection, scaling), center images (calculate position offset), or validate sizes (check image loaded correctly). Return behavior: returns width if found (positive integer, original file width), returns 0 if invalid (handle not found in g_images map, invalid handle), read-only query (doesn't modify image, safe to call anytime). Use cases: (1) Center image (x = screenWidth/2 - b2dGetImageWidth(img)/2: center horizontally), (2) Bounds check (If mouseX < imgX + b2dGetImageWidth(img) Then inside image), (3) Layout (nextX = x + b2dGetImageWidth(img) + spacing: position next element), (4) Scale (scale = targetWidth / b2dGetImageWidth(img): calculate scale factor). Common patterns: query = w = b2dGetImageWidth(img): use width for calculations; center = x - w/2. Animation sheets: returns full sheet width (NOT frame width, use stored frameWidth for individual frames), example (256x128 sheet with 64x64 frames returns 256, not 64). Performance: query cost zero (map lookup and integer read, trivial CPU operation), safe to call every frame (no GPU cost, read-only operation). Related: b2dGetImageHeight queries height (returns full texture height in pixels), b2dLoadImage loads image (creates image queried by this function), b2dLoadAnimImage loads animation sheet (returns full sheet width, not frame width).