pub struct Sequence<S> { /* private fields */ }Expand description
Runs members one after another. Time left over when a member completes carries into the next, so frame/tick partitioning never shifts later members.
An empty sequence completes on its first advance. A paused member holds the sequence; cancelled members are skipped. An endlessly repeating member never yields to later members. Control members through the sequence.
use rayengine_core::tween::*;
use std::time::Duration;
let ms = Duration::from_millis;
// Flash red, then fade back to white.
let mut flash = Sequence::new([
Tween::new([255, 255, 255, 255], [255, 40, 40, 255], ms(50)),
Tween::new([255, 40, 40, 255], [255, 255, 255, 255], ms(200)).with_ease(Ease::QuadOut),
]);
assert!(flash.advance(ms(100)).is_none());
assert_eq!(flash.current(), 1);
assert!(flash.advance(ms(150)).is_some());
assert_eq!(flash.value(), Some([255, 255, 255, 255]));Implementations§
Source§impl<S: Tracks> Sequence<S>
impl<S: Tracks> Sequence<S>
Sourcepub fn tracks_mut(&mut self) -> &mut S
pub fn tracks_mut(&mut self) -> &mut S
Members, for adjusting them in place. Changes to a member the group has already finished with take effect only after resetting the group.
Sourcepub fn current(&self) -> usize
pub fn current(&self) -> usize
Index of the running member; equals the member count once finished.
Sourcepub fn advance(&mut self, dt: Duration) -> Option<TweenCompleted>
pub fn advance(&mut self, dt: Duration) -> Option<TweenCompleted>
Advances by explicitly supplied time. Returns one completion on the call that reaches the end; paused, finished and cancelled playback do nothing.
Sourcepub fn resume(&mut self)
pub fn resume(&mut self)
Allows advancement again. Finished or cancelled playback stays so until reset.
Sourcepub fn cancel(&mut self)
pub fn cancel(&mut self)
Stops at the current value without completing; Self::reset rearms.
Sourcepub fn finish(&mut self) -> Option<TweenCompleted>
pub fn finish(&mut self) -> Option<TweenCompleted>
Jumps to the final value and returns the completion immediately, even
while paused. Returns None if already finished or cancelled.
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Whether the end was reached (by advancing or Self::finish).
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Whether Self::cancel stopped playback before the end.
Trait Implementations§
Source§impl<S: Tracks> Animate for Sequence<S>
impl<S: Tracks> Animate for Sequence<S>
Source§fn step(&mut self, dt: Duration) -> Option<Duration>
fn step(&mut self, dt: Duration) -> Option<Duration>
dt from the call that completes the animation, otherwise None.