Sets pivot point to center (convenience function, auto-calculates center from dimensions).
Takes imageHandle (image handle from b2dLoadImage or b2dLoadAnimImage, positive integer).
Returns nothing.
2D Overlay
Parameters & Returns
Parameters
imageHandleInt
Returns
Void
Quick Summary
Sets pivot point to center (convenience function, auto-calculates center from dimensions).
Takes imageHandle (image handle from b2dLoadImage or b2dLoadAnimImage, positive integer).
Returns nothing.
Technical Exegesis...
Sets pivot point to center (convenience function, auto-calculates center from dimensions). Takes imageHandle (image handle from b2dLoadImage or b2dLoadAnimImage, positive integer). Returns nothing. Calculates center coordinates (uses frame dimensions for animations, full image dimensions otherwise), calls b2dSetImageHandle internally (sets handleX/handleY to calculated center), affects all subsequent draws (same behavior as b2dSetImageHandle).
Sets pivot point to center (convenience function, auto-calculates center from dimensions). Takes imageHandle (image handle from b2dLoadImage or b2dLoadAnimImage, positive integer). Returns nothing. Calculates center coordinates (uses frame dimensions for animations, full image dimensions otherwise), calls b2dSetImageHandle internally (sets handleX/handleY to calculated center), affects all subsequent draws (same behavior as b2dSetImageHandle). Use to center sprites (position/rotate/scale from center automatically), align UI elements (center-aligned buttons, icons), or simplify code (avoid manual center calculation). Center calculation: animation images (width = frameWidth, height = frameHeight, center of single frame not full sheet), regular images (width = image.width, height = image.height, center of full image), formula (handleX = width/2, handleY = height/2, integer division). Use cases: (1) Center-aligned sprite (b2dSetImageMidHandle(player): position player by center), (2) Rotation around center (b2dSetImageMidHandle(asteroid): rotate naturally), (3) Scaling from center (b2dSetImageMidHandle(explosion): expand from center), (4) UI buttons (b2dSetImageMidHandle(button): center-align button), (5) Projectiles (b2dSetImageMidHandle(bullet): position/rotate from center). Common patterns: center = b2dSetImageMidHandle(img) convenience; equivalent = b2dSetImageHandle(img, w/2, h/2) manual calculation. Animation behavior: uses frame dimensions (for 256x128 sheet with 64x64 frames, uses 64x64 not 256x128), centers single frame (handle at 32,32 for 64x64 frame), consistent across frames (all frames share same calculated center). Regular image behavior: uses full dimensions (for 128x128 image, handle at 64,64), single image (no frame subdivision). Transform behavior: same as b2dSetImageHandle (position offset, rotation around center, scale from center), position by center (drawX,drawY specify center location in screen coordinates), natural rotation (images rotate around visual center point), symmetric scaling (scales equally in all directions from center). Equivalent to manual calculation: this function equivalent to (w=b2dGetImageWidth(img): h=b2dGetImageHeight(img): b2dSetImageHandle(img, w/2, h/2)), convenience wrapper (saves typing, clearer intent), frame-aware (automatically handles animation frame dimensions). Performance: cost minimal (dimension queries + integer division + b2dSetImageHandle call, trivial CPU operation), one-time cost (set once, affects all subsequent draws until changed), no GPU cost (handle stored in image structure, applied during draw). Validation: ignores if imageHandle invalid (handle not found in g_images map, silently skips), safe with any image type (works with regular and animated images), frame dimension check (uses frameWidth/Height if >0, otherwise full width/height). Related: b2dSetImageHandle manual pivot (set custom handle coordinates), b2dGetImageHandleX queries handleX (reads stored X offset), b2dGetImageHandleY queries handleY (reads stored Y offset), b2dGetImageWidth queries width (used in manual center calculation), b2dGetImageHeight queries height (used in manual center calculation), b2dDrawImage draws with handle (position, rotation, scale affected by handle).