diff --git a/doc/base/classes.xml b/doc/base/classes.xml index c18cba09a4..a65f4abc46 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -44206,10 +44206,10 @@ - + - Stop animating and completely remove a tween, given its object and property/method pair. + Stop animating and completely remove a tween, given its object and property/method pair. Passing empty String as key will remove all tweens for given object. @@ -44224,10 +44224,10 @@ - + - Resets a tween to the initial value (the one given, not the one before the tween), given its object and property/method pair. + Resets a tween to the initial value (the one given, not the one before the tween), given its object and property/method pair. Passing empty String as key will reset all tweens for given object. @@ -44242,10 +44242,10 @@ - + - Continue animating a stopped tween, given its object and property/method pair. + Continue animating a stopped tween, given its object and property/method pair. Passing empty String as key will resume all tweens for given object. @@ -44304,10 +44304,10 @@ - + - Stop animating a tween, given its object and property/method pair. + Stop animating a tween, given its object and property/method pair. Passing empty String as key will stop all tweens for given object. diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index adc8f9c8cf..156f4956bb 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -199,13 +199,13 @@ void Tween::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_tween_process_mode"),&Tween::get_tween_process_mode); ObjectTypeDB::bind_method(_MD("start"),&Tween::start ); - ObjectTypeDB::bind_method(_MD("reset","object","key"),&Tween::reset ); + ObjectTypeDB::bind_method(_MD("reset","object","key"),&Tween::reset, DEFVAL("") ); ObjectTypeDB::bind_method(_MD("reset_all"),&Tween::reset_all ); - ObjectTypeDB::bind_method(_MD("stop","object","key"),&Tween::stop ); + ObjectTypeDB::bind_method(_MD("stop","object","key"),&Tween::stop, DEFVAL("") ); ObjectTypeDB::bind_method(_MD("stop_all"),&Tween::stop_all ); - ObjectTypeDB::bind_method(_MD("resume","object","key"),&Tween::resume ); + ObjectTypeDB::bind_method(_MD("resume","object","key"),&Tween::resume, DEFVAL("") ); ObjectTypeDB::bind_method(_MD("resume_all"),&Tween::resume_all ); - ObjectTypeDB::bind_method(_MD("remove","object","key"),&Tween::remove ); + ObjectTypeDB::bind_method(_MD("remove","object","key"),&Tween::remove, DEFVAL("") ); ObjectTypeDB::bind_method(_MD("remove_all"),&Tween::remove_all ); ObjectTypeDB::bind_method(_MD("seek","time"),&Tween::seek ); ObjectTypeDB::bind_method(_MD("tell"),&Tween::tell ); @@ -723,7 +723,7 @@ bool Tween::reset(Object *p_object, String p_key) { if(object == NULL) continue; - if(object == p_object && data.key == p_key) { + if(object == p_object && (data.key == p_key || p_key == "")) { data.elapsed = 0; data.finish = false; @@ -759,7 +759,7 @@ bool Tween::stop(Object *p_object, String p_key) { Object *object = ObjectDB::get_instance(data.id); if(object == NULL) continue; - if(object == p_object && data.key == p_key) + if(object == p_object && (data.key == p_key || p_key == "")) data.active = false; } pending_update --; @@ -793,7 +793,7 @@ bool Tween::resume(Object *p_object, String p_key) { Object *object = ObjectDB::get_instance(data.id); if(object == NULL) continue; - if(object == p_object && data.key == p_key) + if(object == p_object && (data.key == p_key || p_key == "")) data.active = true; } pending_update --; @@ -821,17 +821,20 @@ bool Tween::remove(Object *p_object, String p_key) { call_deferred("remove", p_object, p_key); return true; } + List::Element *> for_removal; for(List::Element *E=interpolates.front();E;E=E->next()) { InterpolateData& data = E->get(); Object *object = ObjectDB::get_instance(data.id); if(object == NULL) continue; - if(object == p_object && data.key == p_key) { - interpolates.erase(E); - return true; + if(object == p_object && (data.key == p_key || p_key == "")) { + for_removal.push_back(E); } } + for(List::Element *>::Element *E=for_removal.front();E;E=E->next()) { + interpolates.erase(E->get()); + } return true; }