pub struct Parallel<S> { /* private fields */ }Expand description
Runs members simultaneously and completes when every member is done.
An empty group completes on its first advance. Paused members hold the
group open; cancelled members count as done. Read member values through
Self::tracks.
use rayengine_core::{glam::Vec2, tween::*};
use std::time::Duration;
let ms = Duration::from_millis;
let mut pickup = Parallel::new((
Tween::new(Vec2::ZERO, Vec2::new(0.0, -12.0), ms(300)).with_ease(Ease::QuadOut),
Tween::new(1.0_f32, 0.0, ms(500)).with_delay(ms(100)),
))
.with_id(TweenId(7));
assert!(pickup.advance(ms(300)).is_none());
assert_eq!(pickup.tracks().0.value(), Vec2::new(0.0, -12.0));
assert_eq!(pickup.advance(ms(300)), Some(TweenCompleted { id: TweenId(7) }));Implementations§
Source§impl<S: Tracks> Parallel<S>
impl<S: Tracks> Parallel<S>
Sourcepub fn new(tracks: S) -> Self
pub fn new(tracks: S) -> Self
Starts every member together, unpaused, with the default identity.
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 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 Parallel<S>
impl<S: Tracks> Animate for Parallel<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.