pub struct Animator { /* private fields */ }Expand description
Manages the playback state of sprite animations.
Implementations§
Source§impl Animator
Implements playback control for Animator.
impl Animator
Implements playback control for Animator.
Sourcepub fn play(&mut self, animation: SpriteAnimation)
pub fn play(&mut self, animation: SpriteAnimation)
Sourcepub fn update(&mut self, delta_time: f64)
pub fn update(&mut self, delta_time: f64)
Advances the animation by the given delta time.
§Arguments
f64- The time elapsed since the last update, in seconds.
Sourcepub fn current_frame_source(&self) -> Option<Rect>
pub fn current_frame_source(&self) -> Option<Rect>
Returns the source rectangle of the current frame, or None if no animation is playing.
§Returns
Option<Rect>- The current frame’s source rectangle.
Source§impl Animator
Implements animated sprite rendering for Animator.
impl Animator
Implements animated sprite rendering for Animator.
Sourcepub fn draw(
&self,
context: &CanvasRenderingContext2d,
sheet: &SpriteSheet,
transform: &Transform2D,
)
pub fn draw( &self, context: &CanvasRenderingContext2d, sheet: &SpriteSheet, transform: &Transform2D, )
Draws the current frame of this animator onto the canvas.
§Arguments
&CanvasRenderingContext2d- The canvas context.&SpriteSheet- The sprite sheet containing the image.&Transform2D- The world-space transform to apply.
Source§impl Animator
impl Animator
pub fn get_current_animation(&self) -> Option<SpriteAnimation>
pub fn try_get_current_animation(&self) -> Option<SpriteAnimation>
pub fn set_current_animation( &mut self, val: Option<SpriteAnimation>, ) -> &mut Self
pub fn get_state(&self) -> AnimationState
pub fn set_state(&mut self, val: AnimationState) -> &mut Self
pub fn get_flip_x(&self) -> bool
pub fn set_flip_x(&mut self, val: bool) -> &mut Self
pub fn get_flip_y(&self) -> bool
pub fn set_flip_y(&mut self, val: bool) -> &mut Self
Trait Implementations§
impl StructuralPartialEq for Animator
Auto Trait Implementations§
impl Freeze for Animator
impl RefUnwindSafe for Animator
impl Send for Animator
impl Sync for Animator
impl Unpin for Animator
impl UnsafeUnpin for Animator
impl UnwindSafe for Animator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more