method
Anim.pingpong
Anim.pingpong(timer, fps, count) -> int
Returns a frame index that plays forward to count-1, then back to 0, then forward again — a triangle wave over the frames. Ideal for a two-way idle bob or a breathing/pulsing loop where a plain wrap would snap.
Parameters
timerelapsed seconds (a fixed)fpsframes per secondcountnumber of frames in the clipExample
program Demo {
property Idle { timer: fixed = 0.0 }
model Fish { Idle }
handler Run phase Update {
Idle.timer = Idle.timer + Time.delta()
let cell = Anim.pingpong(Idle.timer, 8, 4) # 0 1 2 3 2 1 0 1 ...
print(cell)
}
}