API Reference › Anim › Anim.once
method

Anim.once

Anim.once(timer, fps, count) -> int

Like Anim.frame but for a one-shot clip: the frame is min(floor(timer * fps), count - 1), so once it reaches the last frame it stays there instead of wrapping. Use it for a play-once animation like an explosion or a door opening; pair it with Anim.finished to know when it is done.

Parameters

timerelapsed seconds (a fixed)
fpsframes per second
countnumber of frames in the clip

Example

program Demo {
  property Blast { timer: fixed = 0.0 }
  model Boom { Blast }
  handler Run phase Update {
    Blast.timer = Blast.timer + Time.delta()
    let cell = Anim.once(Blast.timer, 15, 6)
    print(cell)
  }
}
← All symbols