pub struct FrameAnimation { /* private fields */ }Expand description
A playing frame animation: an explicit frame-order array stepped at a fixed fps.
Frame order[i] is displayed for t ∈ [i·d, (i+1)·d) where d = 1/fps;
accumulating exactly one frame duration advances the cursor.
Implementations§
Source§impl FrameAnimation
impl FrameAnimation
Sourcepub fn new(order: impl Into<Vec<usize>>, fps: f32, loop_mode: LoopMode) -> Self
pub fn new(order: impl Into<Vec<usize>>, fps: f32, loop_mode: LoopMode) -> Self
An animation playing order at fps. Starts at the first entry.
§Panics
If order is empty or fps is not positive — both are authoring
errors, not runtime conditions.
Sourcepub fn start_at(self, position: usize) -> Self
pub fn start_at(self, position: usize) -> Self
Start at position within the order (clamped to the last entry) —
For example, an animation may start at order position 1.
Sourcepub fn tick(&mut self, dt: f32) -> bool
pub fn tick(&mut self, dt: f32) -> bool
Advance by dt seconds. Returns true only on the tick where a
LoopMode::Once animation finishes (a completion edge, once).
Large dt steps multiple frames; the leftover carries into the new
frame so long-run timing never drifts.
Sourcepub fn current_frame(&self) -> usize
pub fn current_frame(&self) -> usize
The sheet-frame index to display right now.
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Whether a LoopMode::Once animation has played out.