summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorEmmanuel Barroga <emmanuelbarroga@gmail.com>2019-09-03 15:59:54 -0700
committerEmmanuel Barroga <emmanuelbarroga@gmail.com>2019-10-16 04:26:26 -0700
commit94a00cd9c7753f9f601e2b61cdba3a909746abf7 (patch)
tree1d5a0d85781eb161f3a8db48c2fe51aa57649ea1 /scene
parentd2900347bf0586879df856e807858178d3bde5f4 (diff)
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.
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/animated_sprite.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp
index 0b20b781f0..8943c74010 100644
--- a/scene/2d/animated_sprite.cpp
+++ b/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);
}