From a19e99aacbb6c4d6dd765510ea99ce0a9916944b Mon Sep 17 00:00:00 2001 From: Chaosus Date: Tue, 19 Mar 2019 15:58:37 +0300 Subject: [PATCH] Added signal for Tween emitted at completion --- doc/classes/Tween.xml | 5 +++++ scene/animation/tween.cpp | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/classes/Tween.xml b/doc/classes/Tween.xml index f5f50a75b124..65c4c38aad64 100644 --- a/doc/classes/Tween.xml +++ b/doc/classes/Tween.xml @@ -350,6 +350,11 @@ + + + Emitted when all processes in a tween end. + + diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 6a5d7839f4b7..23998183b8bb 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -223,6 +223,7 @@ void Tween::_bind_methods() { ADD_SIGNAL(MethodInfo("tween_started", PropertyInfo(Variant::OBJECT, "object"), PropertyInfo(Variant::NODE_PATH, "key"))); ADD_SIGNAL(MethodInfo("tween_step", PropertyInfo(Variant::OBJECT, "object"), PropertyInfo(Variant::NODE_PATH, "key"), PropertyInfo(Variant::REAL, "elapsed"), PropertyInfo(Variant::OBJECT, "value"))); ADD_SIGNAL(MethodInfo("tween_completed", PropertyInfo(Variant::OBJECT, "object"), PropertyInfo(Variant::NODE_PATH, "key"))); + ADD_SIGNAL(MethodInfo("tween_all_completed")); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "repeat"), "set_repeat", "is_repeat"); ADD_PROPERTY(PropertyInfo(Variant::INT, "playback_process_mode", PROPERTY_HINT_ENUM, "Physics,Idle"), "set_tween_process_mode", "get_tween_process_mode"); @@ -628,8 +629,10 @@ void Tween::_tween_process(float p_delta) { } pending_update--; - if (all_finished) + if (all_finished) { set_active(false); + emit_signal("tween_all_completed"); + } } void Tween::set_tween_process_mode(TweenProcessMode p_mode) {