Sets current alpha transparency for 2D overlay (0.0-1.0, affects subsequent draw commands).
Takes alphaLevel (transparency level, 0.0=fully transparent/invisible, 1.0=fully opaque, clamped to 0.0-1.0 range).
Returns nothing.
2D Overlay
Parameters & Returns
Parameters
alphaLevelDouble
Returns
Void
Quick Summary
Sets current alpha transparency for 2D overlay (0.0-1.0, affects subsequent draw commands).
Takes alphaLevel (transparency level, 0.0=fully transparent/invisible, 1.0=fully opaque, clamped to 0.0-1.0 range).
Returns nothing.
Technical Exegesis...
Sets current alpha transparency for 2D overlay (0.0-1.0, affects subsequent draw commands). Takes alphaLevel (transparency level, 0.0=fully transparent/invisible, 1.0=fully opaque, clamped to 0.0-1.0 range). Returns nothing. Sets g_currentState.alpha (stores in global state, clamped to valid range, persists until changed). Use to control transparency (fade effects, HUD elements, semi-transparent UI), animate visibility (fade in/out effects), or layer blending (transparent overlays).
Sets current alpha transparency for 2D overlay (0.0-1.0, affects subsequent draw commands). Takes alphaLevel (transparency level, 0.0=fully transparent/invisible, 1.0=fully opaque, clamped to 0.0-1.0 range). Returns nothing. Sets g_currentState.alpha (stores in global state, clamped to valid range, persists until changed). Use to control transparency (fade effects, HUD elements, semi-transparent UI), animate visibility (fade in/out effects), or layer blending (transparent overlays). State behavior: stores alpha in state (g_currentState.alpha, affects all subsequent draw commands), clamped to 0.0-1.0 (values below 0 set to 0, values above 1 set to 1), persists until changed (remains active across frames until b2dSetAlpha called again), affects all draw operations (text, shapes, images, sprites), independent color (alpha separate from RGB set by b2dSetColor). Use cases: (1) Fade effects (b2dSetAlpha(0.5): draw semi-transparent 50% opacity), (2) Animate fade (alpha = Cos(time): pulsing transparency), (3) HUD transparency (b2dSetAlpha(0.8): slightly transparent UI elements), (4) Conditional visibility (If visible Then b2dSetAlpha(1.0) Else b2dSetAlpha(0.0)), (5) Layered effects (draw multiple sprites with varying alpha for depth). Common patterns: set = b2dSetAlpha(level) configure transparency; opaque = b2dSetAlpha(1.0) reset to fully visible. Typical values: 1.0 fully opaque (default, no transparency, 100% visible), 0.75 mostly visible (25% transparent, slight see-through), 0.5 half transparent (50% blend with background, medium transparency), 0.25 mostly transparent (75% transparent, faint visibility), 0.0 fully transparent (invisible, not drawn but still processed). Alpha blending: standard alpha blend (source alpha blended with destination using SRC_ALPHA/INV_SRC_ALPHA), premultiplied alpha NOT used (engine handles standard alpha blending), affects entire draw (all pixels of text/shape/image affected uniformly). Clamping automatic: values <0.0 clamped to 0.0 (negative alpha treated as fully transparent), values >1.0 clamped to 1.0 (over-bright alpha treated as fully opaque), user doesn't need to clamp (engine handles range validation automatically). Performance: set cost zero (single float assignment with two comparisons, trivial CPU operation), state read every draw (GPU reads alpha from constant buffer, minimal cost), safe to change frequently (no GPU sync, instant state change), no cost difference between opaque and transparent (alpha blending always enabled, no performance penalty for transparency). Related: b2dSetColor sets RGB color (0-255, independent from alpha transparency), b2dSetScale sets sprite scale (scaleX/scaleY for image drawing), b2dSetRotation sets sprite rotation (angle in degrees for image drawing).