pub struct AnimationSequence { /* private fields */ }Expand description
A playing multi-step animation.
The caller drives it with tick and reads
current_frame. Pauses, actions, and
completed sequences hold the last frame reached during playback, including
frames crossed within a single tick. The frame is None only until playback
first reaches a frame after construction or reset.
Implementations§
Source§impl AnimationSequence
impl AnimationSequence
Sourcepub fn builder() -> SequenceBuilder
pub fn builder() -> SequenceBuilder
Start building a sequence.
Sourcepub fn tick(&mut self, dt: f32, rng: &mut Rng) -> bool
pub fn tick(&mut self, dt: f32, rng: &mut Rng) -> bool
Advance by dt seconds, drawing random-pause durations from rng.
Returns true only on the tick where a SequenceLoop::Once or
SequenceLoop::PingPongOnce sequence completes (a completion edge,
once).
Large dt steps through as many frames and steps as it covers and
carries the remainder, so long-run timing never drifts. A nonpositive
or non-finite dt is ignored without advancing steps or drawing from
rng; as on every tick, the prior completion edge and action queue
are cleared. In the repeating modes, a cycle that consumes no time
cannot spin: a tick stops after as many consecutive zero-time advances
(zero-duration frames and steps, or durations too small to lower the
accumulated time in f32) as the sequence has playback positions —
frames plus other steps, doubled for ping-pong — and drops the
remainder. Every position in the cycle has then played at least once.
The play-once modes need no such stop: they end after one bounded
pass.
Sourcepub fn current_frame(&self) -> Option<usize>
pub fn current_frame(&self) -> Option<usize>
The sheet-frame index to display right now. Pauses, actions, and
completed sequences hold the last frame reached during playback.
Returns None only before the first frame is reached after construction
or reset.
Sourcepub fn just_completed(&self) -> bool
pub fn just_completed(&self) -> bool
Whether the sequence completed on the most recent
tick.
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Whether a Once or PingPongOnce sequence has played out.
Sourcepub fn take_action(&mut self) -> Option<u32>
pub fn take_action(&mut self) -> Option<u32>
Take the next action id queued by the most recent
tick, oldest first. Drain it in a loop: one
tick can cross several SequenceStep::Action steps. The queue is
cleared at the start of every tick.