Browse Source

Merge pull request #31943 from codecustard/Fixes_invalid_frames_on_reverse_anim

Fixes Reverse Animation Starting on First Frame
Rémi Verschelde 5 years ago
parent
commit
2416fbb4e2
1 changed files with 6 additions and 2 deletions
  1. 6 2
      scene/2d/animated_sprite.cpp

+ 6 - 2
scene/2d/animated_sprite.cpp

@@ -604,10 +604,14 @@ bool AnimatedSprite::_is_playing() const {
 
 void AnimatedSprite::play(const StringName &p_animation, const bool p_backwards) {
 
-	if (p_animation)
+	backwards = p_backwards;
+
+	if (p_animation) {
 		set_animation(p_animation);
+		if (backwards && get_frame() == 0)
+			set_frame(frames->get_frame_count(p_animation) - 1);
+	}
 
-	backwards = p_backwards;
 	_set_playing(true);
 }