[][src]Struct tetra::graphics::animation::Animation

pub struct Animation { /* fields omitted */ }

An animation, cycling between regions of a texture at a regular interval.

Calling advance within your draw method will drive the animation, switching the texture region once the specified time has passed.

Methods

impl Animation[src]

pub fn new(
    texture: Texture,
    frames: Vec<Rectangle>,
    frame_length: Duration
) -> Animation
[src]

Creates a new animation.

pub fn advance(&mut self, ctx: &Context)[src]

Advances the animation's timer, switching the texture region if required.

pub fn advance_by(&mut self, duration: Duration)[src]

Advances the animation's timer by a specified amount, switching the texture region if required.

pub fn restart(&mut self)[src]

Restarts the animation from the first frame.

pub fn texture(&self) -> &Texture[src]

Returns a reference to the texture currently being used by the animation.

pub fn set_texture(&mut self, texture: Texture)[src]

Sets the texture that will be used by the animation.

This method will not change the frame definitions or current state of the animation, so it can be used for e.g. swapping spritesheets. If you need to change the slicing for the new texture, call set_frames.

pub fn frames(&self) -> &[Rectangle][src]

Gets the sections of the texture being displayed for each frame of the animation.

pub fn set_frames(&mut self, new_frames: Vec<Rectangle>)[src]

Sets the sections of the texture being displayed for each frame of the animation.

This method will reset the animation back to frame zero.

pub fn frame_length(&self) -> Duration[src]

Gets the amount of time that each frame of the animation lasts for.

pub fn set_frame_length(&mut self, new_frame_length: Duration)[src]

Sets the amount of time that each frame of the animation lasts for.

Trait Implementations

impl Clone for Animation[src]

impl Debug for Animation[src]

impl Drawable for Animation[src]

Auto Trait Implementations

impl !RefUnwindSafe for Animation

impl !Send for Animation

impl !Sync for Animation

impl Unpin for Animation

impl !UnwindSafe for Animation

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SetParameter for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = !

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,