From b51da466e9fc25fb39e499f1d521a2a0b78c63cf Mon Sep 17 00:00:00 2001 From: sanikoyes Date: Wed, 20 Aug 2014 12:19:22 +0800 Subject: [PATCH] Add remove/remove_all for tween --- scene/animation/tween.cpp | 27 +++++++++++++++++++++++++++ scene/animation/tween.h | 2 ++ 2 files changed, 29 insertions(+) diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index e7876e3bfa4..eebb0d67774 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -115,6 +115,10 @@ void Tween::_bind_methods() { ObjectTypeDB::bind_method(_MD("reset_all"),&Tween::reset_all ); ObjectTypeDB::bind_method(_MD("stop","object,key"),&Tween::stop ); ObjectTypeDB::bind_method(_MD("stop_all"),&Tween::stop_all ); + ObjectTypeDB::bind_method(_MD("resume"),&Tween::resume ); + ObjectTypeDB::bind_method(_MD("resume_all"),&Tween::resume_all ); + ObjectTypeDB::bind_method(_MD("remove"),&Tween::remove ); + ObjectTypeDB::bind_method(_MD("remove_all"),&Tween::remove_all ); ObjectTypeDB::bind_method(_MD("interpolate_property","object","property","initial_val","final_val","times_in_sec","trans_type","ease_type"),&Tween::interpolate_property ); ObjectTypeDB::bind_method(_MD("interpolate_method","object","method","initial_val","final_val","times_in_sec","trans_type","ease_type"),&Tween::interpolate_method ); @@ -485,6 +489,29 @@ bool Tween::resume_all() { return true; } +bool Tween::remove(Variant p_object, String p_key) { + + for(List::Element *E=interpolates.front();E;E=E->next()) { + + InterpolateData& data = E->get(); + if(data.object == p_object && data.key == p_key) { + + interpolates.erase(E); + return true; + } + } + return true; +} + +bool Tween::remove_all() { + + set_active(false); + _set_process(false); + interpolates.clear(); + return true; +} + + bool Tween::_calc_delta_val(InterpolateData& p_data) { Variant& initial_val = p_data.initial_val; diff --git a/scene/animation/tween.h b/scene/animation/tween.h index 9d087f93caf..5a8186cc21c 100644 --- a/scene/animation/tween.h +++ b/scene/animation/tween.h @@ -130,6 +130,8 @@ public: bool stop_all(); bool resume(Variant p_object, String p_key); bool resume_all(); + bool remove(Variant p_object, String p_key); + bool remove_all(); bool interpolate_property(Variant p_object , String p_property