Add remove/remove_all for tween

This commit is contained in:
sanikoyes 2014-08-20 12:19:22 +08:00
parent f75b8a81d2
commit b51da466e9
2 changed files with 29 additions and 0 deletions
scene/animation

View file

@ -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<InterpolateData>::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;

View file

@ -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