Struct bevy_spritesheet_animation::animation::Animation
source · pub struct Animation { /* private fields */ }
Expand description
A playable animation to assign to a SpritesheetAnimation component.
An animation is composed of one or several AnimationStages.
Parameters like duration, repeat, direction and easing can be specified.
If specified, they will be combined with the parameters of the underlying AnimationStages and AnimationClips.
§Example
let animation_id = library.new_animation(|animation| {
let mut stage1 = AnimationStage::from_clip(some_clip_id);
stage1
.set_duration(AnimationDuration::PerCycle(2000))
.set_easing(Easing::In(EasingVariety::Quadratic));
let mut stage2 = AnimationStage::from_clip(another_clip_id);
stage2
.set_repeat(10)
.set_direction(AnimationDirection::PingPong);
animation
.add_stage(stage1)
.add_stage(stage2)
.set_repeat(AnimationRepeat::Cycles(5));
});
Implementations§
source§impl Animation
impl Animation
sourcepub fn add_stage(&mut self, stage: AnimationStage) -> &mut Self
pub fn add_stage(&mut self, stage: AnimationStage) -> &mut Self
Adds a stage to the animation.
Stages are played in the same order that they are added.
§Arguments
stage
- the stage to add to the animation
§Example
let animation_id = library.new_animation(|animation| {
// Directly add a first clip to the animation as a stage
animation.add_stage(some_clip_id.into());
// Add a second clip
//
// This time, we create an explicit stage to tweak the clip's parameters
let mut stage = AnimationStage::from_clip(some_clip_id);
stage.set_direction(AnimationDirection::Backwards);
animation.add_stage(stage);
});
pub fn stages(&self) -> &[AnimationStage]
pub fn set_duration(&mut self, duration: AnimationDuration) -> &mut Self
pub fn duration(&self) -> &Option<AnimationDuration>
pub fn set_repeat(&mut self, repeat: AnimationRepeat) -> &mut Self
pub fn repeat(&self) -> &Option<AnimationRepeat>
pub fn set_direction(&mut self, direction: AnimationDirection) -> &mut Self
pub fn direction(&self) -> &Option<AnimationDirection>
pub fn set_easing(&mut self, easing: Easing) -> &mut Self
pub fn easing(&self) -> &Option<Easing>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Animation
impl RefUnwindSafe for Animation
impl Send for Animation
impl Sync for Animation
impl Unpin for Animation
impl UnwindSafe for Animation
Blanket Implementations§
source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
Return the
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
Mutably borrows from an owned value. Read more
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
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
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.