diff options
author | kobewi <kobewi4e@gmail.com> | 2024-08-15 08:41:51 +0200 |
---|---|---|
committer | kobewi <kobewi4e@gmail.com> | 2024-08-15 08:41:51 +0200 |
commit | 761d988d4735a2d0d1c30ddfad37693aedbf5f94 (patch) | |
tree | 0c28422c9188d4d2f456aad12b8091dfbfde8be4 /scene/animation | |
parent | 33c30b9e63a58b860cb2f36957c5e25cee34a627 (diff) | |
download | redot-engine-761d988d4735a2d0d1c30ddfad37693aedbf5f94.tar.gz |
Add internal _finish() method to Tweener
Diffstat (limited to 'scene/animation')
-rw-r--r-- | scene/animation/tween.cpp | 17 | ||||
-rw-r--r-- | scene/animation/tween.h | 1 |
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; |