Animation

Trait Animation 

Source
pub trait Animation: Sized {
    type AsociatedAsset: Asset;
    type Query<'w, 's>: QueryData;

    // Required methods
    fn apply(
        animator: &Animator<Self>,
        items: &mut <Self::Query<'_, '_> as WorldQuery>::Item<'_>,
        asset: &Self::AsociatedAsset,
    );
    fn spawn(
        animation: Option<Self>,
        world: &mut World,
        path: String,
        entity: Entity,
    );
    fn duration(&self, asset: &Self::AsociatedAsset) -> f32;
}
Expand description

Defines an animation and how that animation should update the world every tick. Any type that implements this trait can be given state by also implementing the AnimationState trait. To spawn an animation, you can use the spawn_animation method on the Commands struct.

Required Associated Types§

Source

type AsociatedAsset: Asset

The asset that is associated with this animation. For example, aseprite animations are associated with the aseprite asset.

Source

type Query<'w, 's>: QueryData

A query that will allow the animation to effect the component it is attached to.

Required Methods§

Source

fn apply( animator: &Animator<Self>, items: &mut <Self::Query<'_, '_> as WorldQuery>::Item<'_>, asset: &Self::AsociatedAsset, )

This method defines what the animation should do to the component it is attached to every tick.

Source

fn spawn( animation: Option<Self>, world: &mut World, path: String, entity: Entity, )

Describes how to spawn the animation in the world. This method is used by the spawn_animation method on the Commands struct.

Source

fn duration(&self, asset: &Self::AsociatedAsset) -> f32

Given the state of the animation, should return the duration of the animation in seconds.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§