method
Anim.on_frame
Anim.on_frame(entity, frame)
Arms a frame event on an entity's SpriteAnim: the engine sets the component's event_fired flag on the tick the clip first lands on frame — a footstep on the contact cell, a hitbox going live mid-swing. Gameplay reads the flag with Anim.fired in its own handler and reacts (emit its own event, spawn, play a sound). The engine detects the boundary; the game owns the reaction, so it stays inside the deterministic, no-runtime-dispatch event model. Requires the component to carry event_frame and event_fired fields.
Parameters
entitythe entity carrying SpriteAnimframethe cell index that should fire the eventExample
program Demo {
property SpriteAnim { ticks: int = 0, fps: int = 0, frames: int = 0, mode: int = 0, frame: int = 0, event_frame: int = 0, event_fired: int = 0 }
model Hero { SpriteAnim }
entry {
spawn Hero { SpriteAnim { fps: 12, frames: 6, mode: 0 } }
let e = World.query_next(World.prop_id("SpriteAnim"), 0)
Anim.on_frame(e, 3) # fire when the run clip hits its contact frame
tick_fixed()
if Anim.fired(e) { print(1) }
quit()
}
}