summaryrefslogtreecommitdiffstats
path: root/scene/animation
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-08-16 14:35:57 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-08-16 14:35:57 +0200
commit491287aafe243628b9c5ca88c728108fd97b6f67 (patch)
tree76855b8854fb3e338f89fbd6bc125f35bfda9815 /scene/animation
parent0f9925c0f90f490def28fe479e383dbee6b49d3e (diff)
parent761d988d4735a2d0d1c30ddfad37693aedbf5f94 (diff)
downloadredot-engine-491287aafe243628b9c5ca88c728108fd97b6f67.tar.gz
Merge pull request #95545 from KoBeWi/finish_tween!
Add internal `_finish()` method to Tweener
Diffstat (limited to 'scene/animation')
-rw-r--r--scene/animation/tween.cpp17
-rw-r--r--scene/animation/tween.h1
2 files changed, 10 insertions, 8 deletions
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp
index 6a61e8693d..f8bbd704f4 100644
--- a/scene/animation/tween.cpp
+++ b/scene/animation/tween.cpp
@@ -61,6 +61,11 @@ Ref<Tween> Tweener::_get_tween() {
return Ref<Tween>(ObjectDB::get_instance(tween_id));
}
+void Tweener::_finish() {
+ finished = true;
+ emit_signal(SceneStringName(finished));
+}
+
void Tweener::_bind_methods() {
ADD_SIGNAL(MethodInfo("finished"));
}
@@ -612,9 +617,8 @@ bool PropertyTweener::step(double &r_delta) {
return true;
} else {
target_instance->set_indexed(property, final_val);
- finished = true;
r_delta = elapsed_time - delay - duration;
- emit_signal(SceneStringName(finished));
+ _finish();
return false;
}
}
@@ -672,9 +676,8 @@ bool IntervalTweener::step(double &r_delta) {
r_delta = 0;
return true;
} else {
- finished = true;
r_delta = elapsed_time - duration;
- emit_signal(SceneStringName(finished));
+ _finish();
return false;
}
}
@@ -715,9 +718,8 @@ bool CallbackTweener::step(double &r_delta) {
ERR_FAIL_V_MSG(false, "Error calling method from CallbackTweener: " + Variant::get_callable_error_text(callback, nullptr, 0, ce) + ".");
}
- finished = true;
r_delta = elapsed_time - delay;
- emit_signal(SceneStringName(finished));
+ _finish();
return false;
}
@@ -801,9 +803,8 @@ bool MethodTweener::step(double &r_delta) {
r_delta = 0;
return true;
} else {
- finished = true;
r_delta = elapsed_time - delay - duration;
- emit_signal(SceneStringName(finished));
+ _finish();
return false;
}
}
diff --git a/scene/animation/tween.h b/scene/animation/tween.h
index f5ae5e9776..40e1da0ad3 100644
--- a/scene/animation/tween.h
+++ b/scene/animation/tween.h
@@ -50,6 +50,7 @@ protected:
static void _bind_methods();
Ref<Tween> _get_tween();
+ void _finish();
double elapsed_time = 0;
bool finished = false;