Merge pull request #47142 from jmb462/fix-tween-is_active-always-true-after-stop-and-start

[3.x] Fix Tween.is_active() always true after stop() and then start() (Fix #39760 & #39801)
This commit is contained in:
Rémi Verschelde 2021-06-03 11:16:08 +02:00 committed by GitHub
commit ed28ce53bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -873,8 +873,22 @@ bool Tween::start() {
return true; return true;
} }
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 // We want to be activated
set_active(true); set_active(true);
// Don't resume from current position if stop_all() function has been used
if (was_stopped) {
seek(0);
}
was_stopped = false;
return true; return true;
} }
@ -947,6 +961,7 @@ bool Tween::stop(Object *p_object, StringName p_key) {
bool Tween::stop_all() { bool Tween::stop_all() {
// We no longer need to be active since all tweens have been stopped // We no longer need to be active since all tweens have been stopped
set_active(false); set_active(false);
was_stopped = true;
// For each interpolation... // For each interpolation...
pending_update++; pending_update++;

View File

@ -114,7 +114,7 @@ private:
float speed_scale; float speed_scale;
mutable int pending_update; mutable int pending_update;
int uid; int uid;
bool was_stopped = false;
List<InterpolateData> interpolates; List<InterpolateData> interpolates;
struct PendingCommand { struct PendingCommand {