[−][src]Struct tetra::graphics::animation::Animation
An animaton, cycling between regions of a texture at a regular interval.
As the rendering speed of the game is not fixed, use the tick
method in your
update
handler to progress the animation.
Methods
impl Animation
[src]
pub fn new(
texture: Texture,
frames: Vec<Rectangle>,
frame_length: i32
) -> Animation
[src]
texture: Texture,
frames: Vec<Rectangle>,
frame_length: i32
) -> Animation
Creates a new animation.
pub fn tick(&mut self)
[src]
Advances the animation's timer, 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]
Gets 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) -> i32
[src]
Gets the number of ticks that each frame of the animation lasts for.
pub fn set_frame_length(&mut self, new_frame_length: i32)
[src]
Sets the number of ticks that each frame of the animation lasts for.
Trait Implementations
impl Drawable for Animation
[src]
fn draw<P>(&self, ctx: &mut Context, params: P) where
P: Into<DrawParams>,
[src]
P: Into<DrawParams>,
impl Clone for Animation
[src]
fn clone(&self) -> Animation
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for Animation
[src]
Auto Trait Implementations
impl Unpin for Animation
impl !Sync for Animation
impl !Send for Animation
impl !RefUnwindSafe for Animation
impl !UnwindSafe for Animation
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn is_in_subset(&self) -> bool
unsafe fn to_subset_unchecked(&self) -> SS
fn from_subset(element: &SS) -> SP
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
Sets value
as a parameter of self
.