pub struct Animation { /* private fields */ }
Expand description

Definition of an animation

Deserialization format

mode: PingPong
frames:
  - index: 0 # index in the sprite sheet for that frame
    duration: 100 # duration of the frame in milliseconds
  - index: 1
    duration: 100
  - index: 2
    duration: 120

There is also a short-hand notation if all frames have the same duration:

frame_duration: 100
frames: [0, 1, 2] # sequence of frame indices

Implementations

Create a new animation from frames

Create a new animation from index-range, using the same frame duration for each frame.

For more granular configuration, see from_frames

Panics

Panics if the duration is zero

Create a new animation from an index iterator, using the same frame duration for each frame.

Example

You may use this to create a reversed animation:

let animation = Animation::from_iter((0..5).rev(), Duration::from_millis(100));

For more granular configuration, see from_frames

Panics

Panics if the duration is zero

Runs the animation once and then stop playing

Repeat the animation forever

Repeat the animation forever, from a given frame index (loop back to it at the end of the animation)

Repeat the animation forever, going back and forth between the first and last frame.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Extends a collection with the contents of an iterator. Read more

🔬 This is a nightly-only experimental API. (extend_one)

Extends a collection with exactly one element.

🔬 This is a nightly-only experimental API. (extend_one)

Reserves capacity in a collection for the given number of additional elements. Read more

Creates a value from an iterator. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.