pub struct Animation { /* private fields */ }
Expand description
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.
Implementations§
source§impl Animation
impl Animation
sourcepub fn new(
texture: Texture,
frames: Vec<Rectangle>,
frame_length: i32
) -> Animation
pub fn new(
texture: Texture,
frames: Vec<Rectangle>,
frame_length: i32
) -> Animation
Creates a new animation.
sourcepub fn tick(&mut self)
pub fn tick(&mut self)
Advances the animation’s timer, switching the texture region if required.
sourcepub fn set_frames(&mut self, new_frames: Vec<Rectangle>)
pub fn set_frames(&mut self, new_frames: Vec<Rectangle>)
Set new frames for this animation, while keeping the old texture and frame length. This will reset the current animation.
sourcepub fn set_frame_length(&mut self, new_frame_length: i32)
pub fn set_frame_length(&mut self, new_frame_length: i32)
Set the new frame length for this animation. This will make the animation run at the new length right away.
If you want to reset the animation to 0, call restart
Trait Implementations§
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> Pointable for T
impl<T> Pointable for T
§impl<T> SetParameter for T
impl<T> SetParameter for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.