diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-03-03 09:15:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-03 09:15:26 +0100 |
commit | 4d1f83a621a03a42a6ab7765084db84aab32256f (patch) | |
tree | 9d87dc08b556480471023124b9baf8ec87aba111 /scene | |
parent | 43264c63724ef040606936c65a1c24edb9d1f862 (diff) | |
parent | b3d7adc7d676ab849ab5fd6decc7234e402f492c (diff) |
Merge pull request #46609 from jmb462/fix-no-tween-repeat-after-stop
Fix no tween repeat after stop and restart (Fix #39801)
Diffstat (limited to 'scene')
-rw-r--r-- | scene/animation/tween.cpp | 15 | ||||
-rw-r--r-- | scene/animation/tween.h | 1 |
2 files changed, 15 insertions, 1 deletions
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 9b98f3d031..eb35979a47 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -869,8 +869,21 @@ void Tween::start() { return; } + pending_update++; + for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) { + InterpolateData &data = E->get(); + data.active = true; + } + pending_update--; + // We want to be activated set_active(true); + + // Don't resume from current position if stop_all() function has been used + if (was_stopped) { + seek(0); + } + was_stopped = false; } void Tween::reset(Object *p_object, StringName p_key) { @@ -939,7 +952,7 @@ void Tween::stop(Object *p_object, StringName p_key) { void Tween::stop_all() { // We no longer need to be active since all tweens have been stopped set_active(false); - + was_stopped = true; // For each interpolation... pending_update++; for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) { diff --git a/scene/animation/tween.h b/scene/animation/tween.h index 88c02be0bc..142c0c65e0 100644 --- a/scene/animation/tween.h +++ b/scene/animation/tween.h @@ -107,6 +107,7 @@ private: float speed_scale = 1.0; mutable int pending_update = 0; int uid = 0; + bool was_stopped = false; List<InterpolateData> interpolates; |