Skip to content

Commit

Permalink
Add play_unless_already_playing method to AnimationPlayer
Browse files Browse the repository at this point in the history
  • Loading branch information
anchpop committed Oct 23, 2022
1 parent 7989cb2 commit 005508e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion crates/bevy_animation/src/lib.rs
Expand Up @@ -115,14 +115,22 @@ impl Default for AnimationPlayer {

impl AnimationPlayer {
/// Start playing an animation, resetting state of the player
pub fn play(&mut self, handle: Handle<AnimationClip>) -> &mut Self {
pub fn start(&mut self, handle: Handle<AnimationClip>) -> &mut Self {
*self = Self {
animation_clip: handle,
..Default::default()
};
self
}

/// Like `start`, but does nothing if the requested animation is already playing.
pub fn play(&mut self, handle: Handle<AnimationClip>) -> &mut Self {
if self.animation_clip != handle || self.is_paused() {
self.play(handle);
}
self
}

/// Set the animation to repeat
pub fn repeat(&mut self) -> &mut Self {
self.repeat = true;
Expand Down

0 comments on commit 005508e

Please sign in to comment.