소스 검색

Fixes Reverse Animation Starting on First Frame

When playing an animation in reverse, the animation initially starts on frame 0. If it loops, it'll play normally by going to the last frame of the animation, but if it does not... it prematurely stops, since it is already on the last frame (for reversed animation) by starting on frame 0.
Emmanuel Barroga 6 년 전
부모
커밋
94a00cd9c7
1개의 변경된 파일6개의 추가작업 그리고 2개의 파일을 삭제
  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);
 }