Struct bevy_tweening::Delay
source · pub struct Delay<T> { /* private fields */ }
Expand description
A time delay that doesn’t animate anything.
This is generally useful for combining with other tweenables into sequences
and tracks, for example to delay the start of a tween in a track relative to
another track. The menu
example (examples/menu.rs
) uses this technique
to delay the animation of its buttons.
Implementations§
source§impl<T> Delay<T>
impl<T> Delay<T>
sourcepub fn with_completed_event(self, user_data: u64) -> Self
pub fn with_completed_event(self, user_data: u64) -> Self
Enable raising a completed event.
If enabled, the tweenable will raise a TweenCompleted
event when it
completed. This is similar to the set_completed()
callback, but
uses Bevy events instead.
§Example
let delay: Delay<Transform> = Delay::new(Duration::from_secs(5))
.with_completed_event(42);
fn my_system(mut reader: EventReader<TweenCompleted>) {
for ev in reader.read() {
assert_eq!(ev.user_data, 42);
println!("Entity {:?} raised TweenCompleted!", ev.entity);
}
}
sourcepub fn with_completed<C>(self, callback: C) -> Self
pub fn with_completed<C>(self, callback: C) -> Self
Set a callback invoked when the delay completes.
The callback when invoked receives as parameters the [Entity
] on which
the target and the animator are, as well as a reference to the
current Delay
. This is similar to with_completed_event()
, but
with a callback instead.
Only non-looping tweenables can complete.
§Example
let tween = Tween::new(
// [...]
)
.with_completed(|entity, delay| {
println!("Delay of {} seconds elapsed on entity {:?}",
delay.duration().as_secs(), entity);
});
sourcepub fn is_completed(&self) -> bool
pub fn is_completed(&self) -> bool
Check if the delay completed.
sourcepub fn state(&self) -> TweenState
pub fn state(&self) -> TweenState
Get the current tweenable state.
sourcepub fn set_completed<C>(&mut self, callback: C)
pub fn set_completed<C>(&mut self, callback: C)
Set a callback invoked when the animation completes.
The callback when invoked receives as parameters the [Entity
] on which
the target and the animator are, as well as a reference to the
current Tween
.
Only non-looping tweenables can complete.
sourcepub fn clear_completed(&mut self)
pub fn clear_completed(&mut self)
Clear the callback invoked when the animation completes.
See also set_completed()
.
sourcepub fn set_completed_event(&mut self, user_data: u64)
pub fn set_completed_event(&mut self, user_data: u64)
Enable or disable raising a completed event.
If enabled, the tween will raise a TweenCompleted
event when the
animation completed. This is similar to the set_completed()
callback, but uses Bevy events instead.
See with_completed_event()
for details.
sourcepub fn clear_completed_event(&mut self)
pub fn clear_completed_event(&mut self)
Clear the event sent when the animation completes.
See also set_completed_event()
.
Trait Implementations§
source§impl<T: 'static> From<Delay<T>> for BoxedTweenable<T>
impl<T: 'static> From<Delay<T>> for BoxedTweenable<T>
source§impl<T> Tweenable<T> for Delay<T>
impl<T> Tweenable<T> for Delay<T>
source§fn duration(&self) -> Duration
fn duration(&self) -> Duration
source§fn total_duration(&self) -> TotalDuration
fn total_duration(&self) -> TotalDuration
source§fn set_elapsed(&mut self, elapsed: Duration)
fn set_elapsed(&mut self, elapsed: Duration)
source§fn tick(
&mut self,
delta: Duration,
_target: &mut dyn Targetable<T>,
entity: Entity,
events: &mut Mut<'_, Events<TweenCompleted>>
) -> TweenState
fn tick( &mut self, delta: Duration, _target: &mut dyn Targetable<T>, entity: Entity, events: &mut Mut<'_, Events<TweenCompleted>> ) -> TweenState
source§fn set_progress(&mut self, progress: f32)
fn set_progress(&mut self, progress: f32)
source§fn times_completed(&self) -> u32
fn times_completed(&self) -> u32
Auto Trait Implementations§
impl<T> !RefUnwindSafe for Delay<T>
impl<T> Send for Delay<T>
impl<T> Sync for Delay<T>
impl<T> Unpin for Delay<T>
impl<T> !UnwindSafe for Delay<T>
Blanket Implementations§
§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
T
[ShaderType
] for self
. When used in [AsBindGroup
]
derives, it is safe to assume that all images in self
exist.source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.