diff options
| author | groud <gilles.roudiere@gmail.com> | 2018-10-04 12:51:45 +0200 |
|---|---|---|
| committer | groud <gilles.roudiere@gmail.com> | 2018-10-04 12:51:45 +0200 |
| commit | 252d089e6f8905f00f5ef574a3667495163f383e (patch) | |
| tree | baa32d2c0557ef9e55c224b8718f8647020a4a00 /scene/2d/animated_sprite.cpp | |
| parent | cfa373c69f6af64d9fce8f1773a4b795f361a34c (diff) | |
| download | redot-engine-252d089e6f8905f00f5ef574a3667495163f383e.tar.gz | |
Fixes AnimatedSprite2D animation_finished signal triggering too early
Diffstat (limited to 'scene/2d/animated_sprite.cpp')
| -rw-r--r-- | scene/2d/animated_sprite.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp index a33fc844a5..8a5910c10e 100644 --- a/scene/2d/animated_sprite.cpp +++ b/scene/2d/animated_sprite.cpp @@ -395,15 +395,17 @@ void AnimatedSprite::_notification(int p_what) { int fc = frames->get_frame_count(animation); if (frame >= fc - 1) { if (frames->get_animation_loop(animation)) { + emit_signal(SceneStringNames::get_singleton()->animation_finished); frame = 0; } else { + if (!is_over) { + emit_signal(SceneStringNames::get_singleton()->animation_finished); + is_over = true; + } frame = fc - 1; } } else { frame++; - if (frame == fc - 1) { - emit_signal(SceneStringNames::get_singleton()->animation_finished); - } } update(); @@ -625,6 +627,7 @@ void AnimatedSprite::_reset_timeout() { return; timeout = _get_frame_duration(); + is_over = false; } void AnimatedSprite::set_animation(const StringName &p_animation) { @@ -712,4 +715,5 @@ AnimatedSprite::AnimatedSprite() { playing = false; animation = "default"; timeout = 0; + is_over = false; } |
