pub struct AnimationPlayer { /* private fields */ }Expand description
An animation player that controls playback of one animation at a time.
§Example
let mut player = AnimationPlayer::new();
player.play(&idle_anim);
player.play(&run_anim);
// In update:
let events = player.update(dt);
for event in events {
if event == "footstep" { play_sound("step.wav"); }
}Implementations§
Source§impl AnimationPlayer
impl AnimationPlayer
Sourcepub fn play(&mut self, anim: &Animation)
pub fn play(&mut self, anim: &Animation)
Start playing an animation.
If restart is true, always restarts from frame 0.
If false, only restarts if it’s a different animation.
Sourcepub fn current_name(&self) -> Option<&str>
pub fn current_name(&self) -> Option<&str>
Get the current animation name, if any.
Sourcepub fn current_frame_rect(&self) -> Option<(u32, u32, f32, f32)>
pub fn current_frame_rect(&self) -> Option<(u32, u32, f32, f32)>
Get the current frame’s source rectangle (UV region in the sprite sheet).
Sourcepub fn frame_index(&self) -> usize
pub fn frame_index(&self) -> usize
Get the current frame index.
Sourcepub fn state(&self) -> AnimationState
pub fn state(&self) -> AnimationState
Get the playback state.
Trait Implementations§
Source§impl Debug for AnimationPlayer
impl Debug for AnimationPlayer
Auto Trait Implementations§
impl Freeze for AnimationPlayer
impl RefUnwindSafe for AnimationPlayer
impl Send for AnimationPlayer
impl Sync for AnimationPlayer
impl Unpin for AnimationPlayer
impl UnsafeUnpin for AnimationPlayer
impl UnwindSafe for AnimationPlayer
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