API Reference › Anim › Anim.clip
method

Anim.clip

Anim.clip(name, frames, fps, mode)

Registers (or updates) a spritesheet clip under a name, so gameplay refers to a motion by name — Anim.play(entity, "run") — instead of repeating its frame count and rate everywhere. The clip stores frames (cell count), fps (rate) and mode (0 loop, 1 once, 2 ping-pong). Names compare by identity (a string literal interns to one pointer), and the registry holds up to 32 clips. Registering the same name again overwrites it.

Parameters

namethe clip name (a string)
framesnumber of cells in the clip
fpsplayback rate in frames per second
mode0 loop, 1 once (clamp on last), 2 ping-pong

Example

program Demo {
  property SpriteAnim { ticks: int = 0, fps: int = 0, frames: int = 0, mode: int = 0, frame: int = 0 }
  model Hero { SpriteAnim }
  entry {
    Anim.clip("idle", 2, 4, 0)          # a slow 2-frame idle loop
    Anim.clip("run",  6, 12, 0)         # a 6-frame run
    Anim.clip("hit",  3, 15, 1)         # a one-shot hit reaction
    spawn Hero { SpriteAnim { } }
    Anim.play(World.query_next(World.prop_id("SpriteAnim"), 0), "run")
    quit()
  }
}
← All symbols