summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-10-07 11:17:14 +0200
committerGitHub <noreply@github.com>2018-10-07 11:17:14 +0200
commitea65a1bbb3d12617093c72b537216cb31f89949d (patch)
tree9a2732767c0c738f4724624bb8c3a23c82d6f58d /scene/2d
parent32ee3bf092724885d052ec897f0a7ced40c3ef0f (diff)
parent252d089e6f8905f00f5ef574a3667495163f383e (diff)
Merge pull request #22712 from groud/fix_animation_finished_signal
Fixes AnimatedSprite2D animation_finished signal triggering too early
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/animated_sprite.cpp10
-rw-r--r--scene/2d/animated_sprite.h1
2 files changed, 8 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;
}
diff --git a/scene/2d/animated_sprite.h b/scene/2d/animated_sprite.h
index cc49465403..7270ee4d0e 100644
--- a/scene/2d/animated_sprite.h
+++ b/scene/2d/animated_sprite.h
@@ -135,6 +135,7 @@ class AnimatedSprite : public Node2D {
bool centered;
Point2 offset;
+ bool is_over;
float timeout;
bool hflip;