Struct bevy_tweening::Animator
source · pub struct Animator<T: Component> {
pub state: AnimatorState,
/* private fields */
}
Expand description
Component to control the animation of another component.
The animated component is the component located on the same entity as the
Animator<T>
itself.
Fields§
§state: AnimatorState
Control if this animation is played or not.
Implementations§
source§impl<T: Component> Animator<T>
impl<T: Component> Animator<T>
sourcepub fn new(tween: impl Tweenable<T> + 'static) -> Self
pub fn new(tween: impl Tweenable<T> + 'static) -> Self
Create a new animator component from a single tweenable.
sourcepub fn with_state(self, state: AnimatorState) -> Self
pub fn with_state(self, state: AnimatorState) -> Self
Set the initial playback state of the animator.
sourcepub fn with_speed(self, speed: f32) -> Self
pub fn with_speed(self, speed: f32) -> Self
Set the initial speed of the animator. See Animator::set_speed
for
details.
sourcepub fn set_speed(&mut self, speed: f32)
pub fn set_speed(&mut self, speed: f32)
Set the animation speed. Defaults to 1.
A speed of 2 means the animation will run twice as fast while a speed of 0.1 will result in a 10x slowed animation.
sourcepub fn speed(&self) -> f32
pub fn speed(&self) -> f32
Get the animation speed.
See set_speed()
for a definition of what the animation speed is.
sourcepub fn set_tweenable(&mut self, tween: impl Tweenable<T> + 'static)
pub fn set_tweenable(&mut self, tween: impl Tweenable<T> + 'static)
Set the top-level tweenable item this animator controls.
sourcepub fn tweenable(&self) -> &dyn Tweenable<T>
pub fn tweenable(&self) -> &dyn Tweenable<T>
Get the top-level tweenable this animator is currently controlling.
sourcepub fn tweenable_mut(&mut self) -> &mut dyn Tweenable<T>
pub fn tweenable_mut(&mut self) -> &mut dyn Tweenable<T>
Get the top-level mutable tweenable this animator is currently controlling.
sourcepub fn stop(&mut self)
pub fn stop(&mut self)
Stop animation playback and rewind the animation.
This changes the animator state to AnimatorState::Paused
and rewind its
tweenable.
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for Animator<T>
impl<T> Send for Animator<T>
impl<T> Sync for Animator<T>
impl<T> Unpin for Animator<T>
impl<T> !UnwindSafe for Animator<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<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut Components, storages: &mut Storages, ids: &mut impl FnMut(ComponentId) )
unsafe fn from_components<T, F>(ctx: &mut T, func: &mut F) -> C
§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.