From f75b8a81d2f356627731633471b2fe992daa1edf Mon Sep 17 00:00:00 2001 From: sanikoyes Date: Wed, 20 Aug 2014 12:01:41 +0800 Subject: Add tween support for godot --- scene/animation/tween.cpp | 684 ++++++++++++++++++++++++++++++++ scene/animation/tween.h | 161 ++++++++ scene/animation/tween_interpolaters.cpp | 407 +++++++++++++++++++ scene/register_scene_types.cpp | 2 + 4 files changed, 1254 insertions(+) create mode 100644 scene/animation/tween.cpp create mode 100644 scene/animation/tween.h create mode 100644 scene/animation/tween_interpolaters.cpp diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp new file mode 100644 index 0000000000..e7876e3bfa --- /dev/null +++ b/scene/animation/tween.cpp @@ -0,0 +1,684 @@ +/*************************************************************************/ +/* tween.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "tween.h" + +bool Tween::_set(const StringName& p_name, const Variant& p_value) { + + String name=p_name; + + if (name=="playback/speed" || name=="speed") { //bw compatibility + set_speed(p_value); + + } else if (name=="playback/active") { + set_active(p_value); + } + return true; +} + +bool Tween::_get(const StringName& p_name,Variant &r_ret) const { + + String name=p_name; + + if (name=="playback/speed") { //bw compatibility + + r_ret=speed_scale; + } else if (name=="playback/active") { + + r_ret=is_active(); + } + return true; +} + +void Tween::_get_property_list(List *p_list) const { + + p_list->push_back( PropertyInfo( Variant::BOOL, "playback/active", PROPERTY_HINT_NONE,"" ) ); + p_list->push_back( PropertyInfo( Variant::REAL, "playback/speed", PROPERTY_HINT_RANGE, "-64,64,0.01") ); +} + +void Tween::_notification(int p_what) { + + switch(p_what) { + + case NOTIFICATION_ENTER_SCENE: { + + if (!processing) { + //make sure that a previous process state was not saved + //only process if "processing" is set + set_fixed_process(false); + set_process(false); + } + } break; + case NOTIFICATION_READY: { + + } break; + case NOTIFICATION_PROCESS: { + if (tween_process_mode==TWEEN_PROCESS_FIXED) + break; + + if (processing) + _tween_process( get_process_delta_time() ); + } break; + case NOTIFICATION_FIXED_PROCESS: { + + if (tween_process_mode==TWEEN_PROCESS_IDLE) + break; + + if (processing) + _tween_process( get_fixed_process_delta_time() ); + } break; + case NOTIFICATION_EXIT_SCENE: { + + stop_all(); + } break; + } +} + +void Tween::_bind_methods() { + + ObjectTypeDB::bind_method(_MD("is_active"),&Tween::is_active ); + ObjectTypeDB::bind_method(_MD("set_active","active"),&Tween::set_active ); + + ObjectTypeDB::bind_method(_MD("set_speed","speed"),&Tween::set_speed); + ObjectTypeDB::bind_method(_MD("get_speed"),&Tween::get_speed); + + ObjectTypeDB::bind_method(_MD("set_tween_process_mode","mode"),&Tween::set_tween_process_mode); + 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_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("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 ); + + ADD_SIGNAL( MethodInfo("tween_start", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key")) ); + ADD_SIGNAL( MethodInfo("tween_step", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key"), PropertyInfo( Variant::OBJECT,"value")) ); + ADD_SIGNAL( MethodInfo("tween_complete", PropertyInfo( Variant::INT,"id")) ); + + //ADD_PROPERTY( PropertyInfo( Variant::BOOL, "activate"), _SCS("set_active"), _SCS("is_active")); + + BIND_CONSTANT(TRANS_LINEAR); + BIND_CONSTANT(TRANS_SINE); + BIND_CONSTANT(TRANS_QUINT); + BIND_CONSTANT(TRANS_QUART); + BIND_CONSTANT(TRANS_QUAD); + BIND_CONSTANT(TRANS_EXPO); + BIND_CONSTANT(TRANS_ELASTIC); + BIND_CONSTANT(TRANS_CUBIC); + BIND_CONSTANT(TRANS_CIRC); + BIND_CONSTANT(TRANS_BOUNCE); + BIND_CONSTANT(TRANS_BACK); + + BIND_CONSTANT(EASE_IN); + BIND_CONSTANT(EASE_OUT); + BIND_CONSTANT(EASE_IN_OUT); + BIND_CONSTANT(EASE_OUT_IN); +} + +Variant Tween::_run_equation(InterpolateData& p_data) { + + Variant& initial_val = p_data.initial_val; + Variant& delta_val = p_data.delta_val; + Variant result; + +#define APPLY_EQUATION(element)\ + r.element = _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed, i.element, d.element, p_data.times_in_sec); + + switch(initial_val.get_type()) + { + case Variant::INT: + result = (int) _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed, (int) initial_val, (int) delta_val, p_data.times_in_sec); + break; + + case Variant::REAL: + result = _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed, (real_t) initial_val, (real_t) delta_val, p_data.times_in_sec); + break; + + case Variant::VECTOR2: + { + Vector2 i = initial_val; + Vector2 d = delta_val; + Vector2 r; + + APPLY_EQUATION(x); + APPLY_EQUATION(y); + + result = r; + } + break; + + case Variant::VECTOR3: + { + Vector3 i = initial_val; + Vector3 d = delta_val; + Vector3 r; + + APPLY_EQUATION(x); + APPLY_EQUATION(y); + APPLY_EQUATION(z); + + result = r; + } + break; + + case Variant::MATRIX3: + { + Matrix3 i = initial_val; + Matrix3 d = delta_val; + Matrix3 r; + + APPLY_EQUATION(elements[0][0]); + APPLY_EQUATION(elements[0][1]); + APPLY_EQUATION(elements[0][2]); + APPLY_EQUATION(elements[1][0]); + APPLY_EQUATION(elements[1][1]); + APPLY_EQUATION(elements[1][2]); + APPLY_EQUATION(elements[2][0]); + APPLY_EQUATION(elements[2][1]); + APPLY_EQUATION(elements[2][2]); + + result = r; + } + break; + + case Variant::MATRIX32: + { + Matrix3 i = initial_val; + Matrix3 d = delta_val; + Matrix3 r; + + APPLY_EQUATION(elements[0][0]); + APPLY_EQUATION(elements[0][1]); + APPLY_EQUATION(elements[1][0]); + APPLY_EQUATION(elements[1][1]); + APPLY_EQUATION(elements[2][0]); + APPLY_EQUATION(elements[2][1]); + + result = r; + } + break; + case Variant::QUAT: + { + Quat i = initial_val; + Quat d = delta_val; + Quat r; + + APPLY_EQUATION(x); + APPLY_EQUATION(y); + APPLY_EQUATION(z); + APPLY_EQUATION(w); + + result = r; + } + break; + case Variant::_AABB: + { + AABB i = initial_val; + AABB d = delta_val; + AABB r; + + APPLY_EQUATION(pos.x); + APPLY_EQUATION(pos.y); + APPLY_EQUATION(pos.z); + APPLY_EQUATION(size.x); + APPLY_EQUATION(size.y); + APPLY_EQUATION(size.z); + + result = r; + } + break; + case Variant::TRANSFORM: + { + Transform i = initial_val; + Transform d = delta_val; + Transform r; + + APPLY_EQUATION(basis.elements[0][0]); + APPLY_EQUATION(basis.elements[0][1]); + APPLY_EQUATION(basis.elements[0][2]); + APPLY_EQUATION(basis.elements[1][0]); + APPLY_EQUATION(basis.elements[1][1]); + APPLY_EQUATION(basis.elements[1][2]); + APPLY_EQUATION(basis.elements[2][0]); + APPLY_EQUATION(basis.elements[2][1]); + APPLY_EQUATION(basis.elements[2][2]); + APPLY_EQUATION(origin.x); + APPLY_EQUATION(origin.y); + APPLY_EQUATION(origin.z); + + result = r; + } + break; + case Variant::COLOR: + { + Color i = initial_val; + Color d = delta_val; + Color r; + + APPLY_EQUATION(r); + APPLY_EQUATION(g); + APPLY_EQUATION(b); + APPLY_EQUATION(a); + + result = r; + } + break; + }; +#undef APPLY_EQUATION + + return result; +} + +bool Tween::_apply_tween_value(InterpolateData& p_data, Variant& value) { + + Variant& object = p_data.object; + + if(p_data.is_method) { + + Variant *arg[1] = { &value }; + + Variant::CallError error; + object.call(p_data.key, (const Variant **) arg, 1, error); + if(error.error == Variant::CallError::CALL_OK) + return true; + + return false; + + } else { + + bool valid = false; + object.set(p_data.key,value, &valid); + return valid; + } + return true; +} + +void Tween::_tween_process(float p_delta) { + + if (speed_scale == 0) + return; + p_delta *= speed_scale; + + for(List::Element *E=interpolates.front();E;E=E->next()) { + + InterpolateData& data = E->get(); + if(!data.active || data.elapsed == data.times_in_sec) + continue; + + if(data.elapsed == 0) + emit_signal("tween_start",data.object,data.key); + + data.elapsed += p_delta; + if(data.elapsed > data.times_in_sec) + data.elapsed = data.times_in_sec; + + Variant result = _run_equation(data); + emit_signal("tween_step",data.object,data.key,result); + + _apply_tween_value(data, result); + + if(data.elapsed == data.times_in_sec) + emit_signal("tween_complete",data.object,data.key); + } +} + +void Tween::set_tween_process_mode(TweenProcessMode p_mode) { + + if (tween_process_mode==p_mode) + return; + + bool pr = processing; + if (pr) + _set_process(false); + tween_process_mode=p_mode; + if (pr) + _set_process(true); +} + +Tween::TweenProcessMode Tween::get_tween_process_mode() const { + + return tween_process_mode; +} + +void Tween::_set_process(bool p_process,bool p_force) { + + if (processing==p_process && !p_force) + return; + + switch(tween_process_mode) { + + case TWEEN_PROCESS_FIXED: set_fixed_process(p_process && active); break; + case TWEEN_PROCESS_IDLE: set_process(p_process && active); break; + } + + processing=p_process; +} + +bool Tween::is_active() const { + + return active; +} + +void Tween::set_active(bool p_active) { + + if (active==p_active) + return; + + active=p_active; + _set_process(processing,true); +} + +void Tween::set_speed(float p_speed) { + + speed_scale=p_speed; +} + +float Tween::get_speed() const { + + return speed_scale; +} + +bool Tween::start() { + + set_active(true); + _set_process(true); + return true; +} + +bool Tween::reset(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) + _apply_tween_value(data, data.initial_val); + } + return true; +} + +bool Tween::reset_all() { + + for(List::Element *E=interpolates.front();E;E=E->next()) { + + InterpolateData& data = E->get(); + _apply_tween_value(data, data.initial_val); + } + return true; +} + +bool Tween::stop(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) + data.active = false; + } + return true; +} + +bool Tween::stop_all() { + + set_active(false); + _set_process(false); + + for(List::Element *E=interpolates.front();E;E=E->next()) { + + InterpolateData& data = E->get(); + data.active = false; + } + return true; +} + +bool Tween::resume(Variant p_object, String p_key) { + + set_active(true); + _set_process(true); + + for(List::Element *E=interpolates.front();E;E=E->next()) { + + InterpolateData& data = E->get(); + if(data.object == p_object && data.key == p_key) + data.active = true; + } + return true; +} + +bool Tween::resume_all() { + + set_active(true); + _set_process(true); + + for(List::Element *E=interpolates.front();E;E=E->next()) { + + InterpolateData& data = E->get(); + data.active = true; + } + return true; +} + +bool Tween::_calc_delta_val(InterpolateData& p_data) { + + Variant& initial_val = p_data.initial_val; + Variant& delta_val = p_data.delta_val; + Variant& final_val = p_data.final_val; + + switch(initial_val.get_type()) { + case Variant::INT: + delta_val = (int) final_val - (int) initial_val; + break; + + case Variant::REAL: + delta_val = (real_t) final_val - (real_t) initial_val; + break; + + case Variant::VECTOR2: + delta_val = final_val.operator Vector2() - initial_val.operator Vector2(); + break; + + case Variant::VECTOR3: + delta_val = final_val.operator Vector3() - initial_val.operator Vector3(); + break; + + case Variant::MATRIX3: + { + Matrix3 i = initial_val; + Matrix3 f = final_val; + delta_val = Matrix3(f.elements[0][0] - i.elements[0][0], + f.elements[0][1] - i.elements[0][1], + f.elements[0][2] - i.elements[0][2], + f.elements[1][0] - i.elements[1][0], + f.elements[1][1] - i.elements[1][1], + f.elements[1][2] - i.elements[1][2], + f.elements[2][0] - i.elements[2][0], + f.elements[2][1] - i.elements[2][1], + f.elements[2][2] - i.elements[2][2] + ); + } + break; + + case Variant::MATRIX32: + { + Matrix32 i = initial_val; + Matrix32 f = final_val; + Matrix32 d = Matrix32(); + d[0][0] = f.elements[0][0] - i.elements[0][0]; + d[0][1] = f.elements[0][1] - i.elements[0][1]; + d[1][0] = f.elements[1][0] - i.elements[1][0]; + d[1][1] = f.elements[1][1] - i.elements[1][1]; + d[2][0] = f.elements[2][0] - i.elements[2][0]; + d[2][1] = f.elements[2][1] - i.elements[2][1]; + delta_val = d; + } + break; + case Variant::QUAT: + delta_val = final_val.operator Quat() - initial_val.operator Quat(); + break; + case Variant::_AABB: + { + AABB i = initial_val; + AABB f = final_val; + delta_val = AABB(f.pos - i.pos, f.size - i.size); + } + break; + case Variant::TRANSFORM: + { + Transform i = initial_val; + Transform f = final_val; + Transform d; + d.set(f.basis.elements[0][0] - i.basis.elements[0][0], + f.basis.elements[0][1] - i.basis.elements[0][1], + f.basis.elements[0][2] - i.basis.elements[0][2], + f.basis.elements[1][0] - i.basis.elements[1][0], + f.basis.elements[1][1] - i.basis.elements[1][1], + f.basis.elements[1][2] - i.basis.elements[1][2], + f.basis.elements[2][0] - i.basis.elements[2][0], + f.basis.elements[2][1] - i.basis.elements[2][1], + f.basis.elements[2][2] - i.basis.elements[2][2], + f.origin.x - i.origin.x, + f.origin.y - i.origin.y, + f.origin.z - i.origin.z + ); + + delta_val = d; + } + break; + case Variant::COLOR: + { + Color i = initial_val; + Color f = final_val; + delta_val = Color(f.r - i.r, f.g - i.g, f.b - i.b, f.a - i.a); + } + break; + + default: + ERR_PRINT("Invalid param type, except(int/real/vector2/vector/matrix/matrix32/quat/aabb/transform/color)"); + return false; + }; + return true; +} + +bool Tween::interpolate_property(Variant p_object + , String p_property + , Variant p_initial_val + , Variant p_final_val + , real_t p_times_in_sec + , TransitionType p_trans_type + , EaseType p_ease_type +) { + + ERR_FAIL_COND_V(p_object.get_type() != Variant::OBJECT, false); + ERR_FAIL_COND_V(p_initial_val.get_type() != p_final_val.get_type(), false); + ERR_FAIL_COND_V(p_times_in_sec <= 0, false); + + bool prop_found = false; + Object *obj = (Object *) p_object; + List props; + obj->get_property_list(&props); + for(List::Element *E=props.front();E;E=E->next()) { + + PropertyInfo& prop=E->get(); + if(prop.name==p_property) + { + prop_found = true; + break; + } + } + ERR_FAIL_COND_V(!prop_found, false); + + InterpolateData data; + data.active = true; + data.is_method = false; + data.elapsed = 0; + + data.object = p_object; + data.key = p_property; + data.initial_val = p_initial_val; + data.final_val = p_final_val; + data.times_in_sec = p_times_in_sec; + data.trans_type = p_trans_type; + data.ease_type = p_ease_type; + + if(!_calc_delta_val(data)) + return false; + + interpolates.push_back(data); + return true; +} + +bool Tween::interpolate_method(Variant p_object + , String p_method + , Variant p_initial_val + , Variant p_final_val + , real_t p_times_in_sec + , TransitionType p_trans_type + , EaseType p_ease_type +) { + + ERR_FAIL_COND_V(p_object.get_type() != Variant::OBJECT, false); + ERR_FAIL_COND_V(p_initial_val.get_type() != p_final_val.get_type(), false); + ERR_FAIL_COND_V(p_times_in_sec <= 0, false); + + Object *obj = (Object *) p_object; + ERR_FAIL_COND_V(!obj->has_method(p_method), false); + + InterpolateData data; + data.active = true; + data.is_method = true; + data.elapsed = 0; + + data.object = p_object; + data.key = p_method; + data.initial_val = p_initial_val; + data.final_val = p_final_val; + data.times_in_sec = p_times_in_sec; + data.trans_type = p_trans_type; + data.ease_type = p_ease_type; + + if(!_calc_delta_val(data)) + return false; + + interpolates.push_back(data); + return true; +} + +Tween::Tween() { + + //String autoplay; + tween_process_mode=TWEEN_PROCESS_IDLE; + processing=false; + active=false; + speed_scale=1; +} + +Tween::~Tween() { + +} diff --git a/scene/animation/tween.h b/scene/animation/tween.h new file mode 100644 index 0000000000..9d087f93ca --- /dev/null +++ b/scene/animation/tween.h @@ -0,0 +1,161 @@ +/*************************************************************************/ +/* tween.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef TWEEN_H +#define TWEEN_H + +#include "scene/main/node.h" + + +class Tween : public Node { + + OBJ_TYPE( Tween, Node ); + +public: + enum TweenProcessMode { + TWEEN_PROCESS_FIXED, + TWEEN_PROCESS_IDLE, + }; + + enum TransitionType { + TRANS_LINEAR, + TRANS_SINE, + TRANS_QUINT, + TRANS_QUART, + TRANS_QUAD, + TRANS_EXPO, + TRANS_ELASTIC, + TRANS_CUBIC, + TRANS_CIRC, + TRANS_BOUNCE, + TRANS_BACK, + + TRANS_COUNT, + }; + + enum EaseType { + EASE_IN, + EASE_OUT, + EASE_IN_OUT, + EASE_OUT_IN, + + EASE_COUNT, + }; + +private: + + struct InterpolateData { + bool active; + bool is_method; + real_t elapsed; + + Variant object; + String key; + Variant initial_val; + Variant delta_val; + Variant final_val; + real_t times_in_sec; + TransitionType trans_type; + EaseType ease_type; + }; + + String autoplay; + TweenProcessMode tween_process_mode; + bool processing; + bool active; + float speed_scale; + + List interpolates; + + typedef real_t (*interpolater)(real_t t, real_t b, real_t c, real_t d); + static interpolater interpolaters[TRANS_COUNT][EASE_COUNT]; + + real_t _run_equation(TransitionType p_trans_type, EaseType p_ease_type, real_t t, real_t b, real_t c, real_t d); + Variant _run_equation(InterpolateData& p_data); + bool _calc_delta_val(InterpolateData& p_data); + bool _apply_tween_value(InterpolateData& p_data, Variant& value); + + void _tween_process(float p_delta); + void _set_process(bool p_process,bool p_force=false); + +protected: + + bool _set(const StringName& p_name, const Variant& p_value); + bool _get(const StringName& p_name,Variant &r_ret) const; + void _get_property_list(List *p_list) const; + void _notification(int p_what); + + static void _bind_methods(); + +public: + + bool is_active() const; + void set_active(bool p_active); + + void set_tween_process_mode(TweenProcessMode p_mode); + TweenProcessMode get_tween_process_mode() const; + + void set_speed(float p_speed); + float get_speed() const; + + bool start(); + bool reset(Variant p_object, String p_key); + bool reset_all(); + bool stop(Variant p_object, String p_key); + bool stop_all(); + bool resume(Variant p_object, String p_key); + bool resume_all(); + + bool interpolate_property(Variant p_object + , String p_property + , Variant p_initial_val + , Variant p_final_val + , real_t p_times_in_sec + , TransitionType p_trans_type + , EaseType p_ease_type + ); + + bool interpolate_method(Variant p_object + , String p_method + , Variant p_initial_val + , Variant p_final_val + , real_t p_times_in_sec + , TransitionType p_trans_type + , EaseType p_ease_type + ); + + Tween(); + ~Tween(); +}; + +VARIANT_ENUM_CAST( Tween::TweenProcessMode ); +VARIANT_ENUM_CAST( Tween::TransitionType ); +VARIANT_ENUM_CAST( Tween::EaseType ); + +#endif + diff --git a/scene/animation/tween_interpolaters.cpp b/scene/animation/tween_interpolaters.cpp new file mode 100644 index 0000000000..7d0f2cd4e0 --- /dev/null +++ b/scene/animation/tween_interpolaters.cpp @@ -0,0 +1,407 @@ +/*************************************************************************/ +/* tween.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "tween.h" + +const real_t pi = 3.1415926535898; + +/////////////////////////////////////////////////////////////////////////// +// linear +/////////////////////////////////////////////////////////////////////////// +namespace linear { + static real_t in(real_t t, real_t b, real_t c, real_t d) + { + return c * t / d + b; + } + + static real_t out(real_t t, real_t b, real_t c, real_t d) + { + return c * t / d + b; + } + + static real_t in_out(real_t t, real_t b, real_t c, real_t d) + { + return c * t / d + b; + } + + static real_t out_in(real_t t, real_t b, real_t c, real_t d) + { + return c * t / d + b; + } +}; +/////////////////////////////////////////////////////////////////////////// +// sine +/////////////////////////////////////////////////////////////////////////// +namespace sine { + static real_t in(real_t t, real_t b, real_t c, real_t d) + { + return -c * cos(t / d * (pi / 2)) + c + b; + } + + static real_t out(real_t t, real_t b, real_t c, real_t d) + { + return c * sin(t / d * (pi / 2)) + b; + } + + static real_t in_out(real_t t, real_t b, real_t c, real_t d) + { + return -c / 2 * (cos(pi * t / d) - 1) + b; + } + + static real_t out_in(real_t t, real_t b, real_t c, real_t d) + { + return (t < d / 2) + ? out(t * 2, b, c / 2, d) + : in((t * 2) - d, b + c / 2, c / 2, d) + ; + } +}; +/////////////////////////////////////////////////////////////////////////// +// quint +/////////////////////////////////////////////////////////////////////////// +namespace quint { + static real_t in(real_t t, real_t b, real_t c, real_t d) + { + return c * pow(t / d, 5) + b; + } + + static real_t out(real_t t, real_t b, real_t c, real_t d) + { + return c * (pow(t / d - 1, 5) + 1) + b; + } + + static real_t in_out(real_t t, real_t b, real_t c, real_t d) + { + t = t / d * 2; + if (t < 1) return c / 2 * pow(t, 5) + b; + return c / 2 * (pow(t - 2, 5) + 2) + b; + } + + static real_t out_in(real_t t, real_t b, real_t c, real_t d) + { + return (t < d / 2) + ? out(t * 2, b, c / 2, d) + : in((t * 2) - d, b + c / 2, c / 2, d) + ; + } +}; +/////////////////////////////////////////////////////////////////////////// +// quart +/////////////////////////////////////////////////////////////////////////// +namespace quart { + static real_t in(real_t t, real_t b, real_t c, real_t d) + { + return c * pow(t / d, 4) + b; + } + + static real_t out(real_t t, real_t b, real_t c, real_t d) + { + return -c * (pow(t / d - 1, 4) - 1) + b; + } + + static real_t in_out(real_t t, real_t b, real_t c, real_t d) + { + t = t / d * 2; + if (t < 1) return c / 2 * pow(t, 4) + b; + return -c / 2 * (pow(t - 2, 4) - 2) + b; + } + + static real_t out_in(real_t t, real_t b, real_t c, real_t d) + { + return (t < d / 2) + ? out(t * 2, b, c / 2, d) + : in((t * 2) - d, b + c / 2, c / 2, d) + ; + } +}; +/////////////////////////////////////////////////////////////////////////// +// quad +/////////////////////////////////////////////////////////////////////////// +namespace quad { + static real_t in(real_t t, real_t b, real_t c, real_t d) + { + return c * pow(t / d, 2) + b; + } + + static real_t out(real_t t, real_t b, real_t c, real_t d) + { + t = t / d; + return -c * t * (t - 2) + b; + } + + static real_t in_out(real_t t, real_t b, real_t c, real_t d) + { + t = t / d * 2; + if (t < 1) return c / 2 * pow(t, 2) + b; + return -c / 2 * ((t - 1) * (t - 3) - 1) + b; + } + + static real_t out_in(real_t t, real_t b, real_t c, real_t d) + { + return (t < d / 2) + ? out(t * 2, b, c / 2, d) + : in((t * 2) - d, b + c / 2, c / 2, d) + ; + } +}; +/////////////////////////////////////////////////////////////////////////// +// expo +/////////////////////////////////////////////////////////////////////////// +namespace expo { + static real_t in(real_t t, real_t b, real_t c, real_t d) + { + if (t == 0) return b; + return c * pow(2, 10 * (t / d - 1)) + b - c * 0.001; + } + + static real_t out(real_t t, real_t b, real_t c, real_t d) + { + if (t == d) return b + c; + return c * 1.001 * (-pow(2, -10 * t / d) + 1) + b; + } + + static real_t in_out(real_t t, real_t b, real_t c, real_t d) + { + if (t == 0) return b; + if (t == d) return b + c; + t = t / d * 2; + if (t < 1) return c / 2 * pow(2, 10 * (t - 1)) + b - c * 0.0005; + return c / 2 * 1.0005 * (-pow(2, -10 * (t - 1)) + 2) + b; + } + + static real_t out_in(real_t t, real_t b, real_t c, real_t d) + { + return (t < d / 2) + ? out(t * 2, b, c / 2, d) + : in((t * 2) - d, b + c / 2, c / 2, d) + ; + } +}; +/////////////////////////////////////////////////////////////////////////// +// elastic +/////////////////////////////////////////////////////////////////////////// +namespace elastic { + static real_t in(real_t t, real_t b, real_t c, real_t d) + { + if (t == 0) return b; + if ((t /= d) == 1) return b + c; + float p = d * 0.3f; + float a = c; + float s = p / 4; + float postFix = a * pow(2,10 * (t -= 1)); // this is a fix, again, with post-increment operators + return -(postFix * sin((t * d - s) * (2 * pi) / p )) + b; + } + + static real_t out(real_t t, real_t b, real_t c, real_t d) + { + if (t == 0) return b; + if ((t /= d) == 1) return b + c; + float p = d * 0.3f; + float a = c; + float s = p / 4; + return (a * pow(2, -10 * t) * sin((t * d - s) * (2 * pi) / p ) + c + b); + } + + static real_t in_out(real_t t, real_t b, real_t c, real_t d) + { + if (t == 0) return b; + if ((t /= d / 2) == 2) return b + c; + float p = d * (0.3f * 1.5f); + float a = c; + float s = p / 4; + + if (t < 1) { + float postFix = a * pow(2, 10 * (t -= 1)); // postIncrement is evil + return -0.5f * (postFix * sin((t * d - s) * (2 * pi) / p)) + b; + } + float postFix = a * pow(2, -10 * (t -= 1)); // postIncrement is evil + return postFix * sin((t * d - s) * (2 * pi) / p ) * 0.5f + c + b; + } + + static real_t out_in(real_t t, real_t b, real_t c, real_t d) + { + return (t < d / 2) + ? out(t * 2, b, c / 2, d) + : in((t * 2) - d, b + c / 2, c / 2, d) + ; + } +}; +/////////////////////////////////////////////////////////////////////////// +// cubic +/////////////////////////////////////////////////////////////////////////// +namespace cubic { + static real_t in(real_t t, real_t b, real_t c, real_t d) + { + return c * (t /= d) * t * t + b; + } + + static real_t out(real_t t, real_t b, real_t c, real_t d) + { + return c * ((t = t / d - 1) * t * t + 1) + b; + } + + static real_t in_out(real_t t, real_t b, real_t c, real_t d) + { + if ((t /= d / 2) < 1) return c / 2 * t * t * t + b; + return c / 2 * ((t -= 2) * t * t + 2) + b; + } + + static real_t out_in(real_t t, real_t b, real_t c, real_t d) + { + return (t < d / 2) + ? out(t * 2, b, c / 2, d) + : in((t * 2) - d, b + c / 2, c / 2, d) + ; + } +}; +/////////////////////////////////////////////////////////////////////////// +// circ +/////////////////////////////////////////////////////////////////////////// +namespace circ { + static real_t in(real_t t, real_t b, real_t c, real_t d) + { + return -c * (sqrt(1 - (t /= d) * t) - 1) + b; + } + + static real_t out(real_t t, real_t b, real_t c, real_t d) + { + return c * sqrt(1 - (t = t / d - 1) * t) + b; + } + + static real_t in_out(real_t t, real_t b, real_t c, real_t d) + { + if ((t /= d / 2) < 1) return -c / 2 * (sqrt(1 - t * t) - 1) + b; + return c / 2 * (sqrt(1 - t * (t -= 2)) + 1) + b; + } + + static real_t out_in(real_t t, real_t b, real_t c, real_t d) + { + return (t < d / 2) + ? out(t * 2, b, c / 2, d) + : in((t * 2) - d, b + c / 2, c / 2, d) + ; + } +}; +/////////////////////////////////////////////////////////////////////////// +// bounce +/////////////////////////////////////////////////////////////////////////// +namespace bounce { + static real_t out(real_t t, real_t b, real_t c, real_t d); + + static real_t in(real_t t, real_t b, real_t c, real_t d) + { + return c - out(d - t, 0, c, d) + b; + } + + static real_t out(real_t t, real_t b, real_t c, real_t d) + { + if ((t /= d) < (1 / 2.75f)) { + return c*(7.5625f*t*t) + b; + } else if (t < (2/2.75f)) { + float postFix = t-=(1.5f/2.75f); + return c*(7.5625f*(postFix)*t + .75f) + b; + } else if (t < (2.5/2.75)) { + float postFix = t-=(2.25f/2.75f); + return c*(7.5625f*(postFix)*t + .9375f) + b; + } else { + float postFix = t-=(2.625f/2.75f); + return c*(7.5625f*(postFix)*t + .984375f) + b; + } + } + + static real_t in_out(real_t t, real_t b, real_t c, real_t d) + { + return (t < d / 2) + ? in(t * 2, b, c / 2, d) + : out((t * 2) - d, b + c / 2, c / 2, d) + ; + } + + static real_t out_in(real_t t, real_t b, real_t c, real_t d) + { + return (t < d / 2) + ? out(t * 2, b, c / 2, d) + : in((t * 2) - d, b + c / 2, c / 2, d) + ; + } +}; +/////////////////////////////////////////////////////////////////////////// +// back +/////////////////////////////////////////////////////////////////////////// +namespace back { + static real_t in(real_t t, real_t b, real_t c, real_t d) + { + float s = 1.70158f; + float postFix = t /= d; + return c * (postFix) * t * ((s + 1) * t - s) + b; + } + + static real_t out(real_t t, real_t b, real_t c, real_t d) + { + float s = 1.70158f; + return c * ((t = t / d- 1) * t * ((s + 1) * t + s) + 1) + b; + } + + static real_t in_out(real_t t, real_t b, real_t c, real_t d) + { + float s = 1.70158f; + if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525f)) + 1) * t - s)) + b; + float postFix = t -= 2; + return c / 2 * ((postFix) * t * (((s *= (1.525f)) + 1) * t + s) + 2) + b; + } + + static real_t out_in(real_t t, real_t b, real_t c, real_t d) + { + return (t < d / 2) + ? out(t * 2, b, c / 2, d) + : in((t * 2) - d, b + c / 2, c / 2, d) + ; + } +}; + +Tween::interpolater Tween::interpolaters[Tween::TRANS_COUNT][Tween::EASE_COUNT] = { + { &linear::in, &linear::out, &linear::in_out, &linear::out_in }, + { &sine::in, &sine::out, &sine::in_out, &sine::out_in }, + { &quint::in, &quint::out, &quint::in_out, &quint::out_in }, + { &quart::in, &quart::out, &quart::in_out, &quart::out_in }, + { &quad::in, &quad::out, &quad::in_out, &quad::out_in }, + { &expo::in, &expo::out, &expo::in_out, &expo::out_in }, + { &elastic::in, &elastic::out, &elastic::in_out, &elastic::out_in }, + { &cubic::in, &cubic::out, &cubic::in_out, &cubic::out_in }, + { &circ::in, &circ::out, &circ::in_out, &circ::out_in }, + { &bounce::in, &bounce::out, &bounce::in_out, &bounce::out_in }, + { &back::in, &back::out, &back::in_out, &back::out_in }, +}; + +real_t Tween::_run_equation(TransitionType p_trans_type, EaseType p_ease_type, real_t t, real_t b, real_t c, real_t d) { + + interpolater cb = interpolaters[p_trans_type][p_ease_type]; + ERR_FAIL_COND_V(cb == NULL, b); + return cb(t, b, c, d); +} + diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index f7d6a246e6..9811de3e4a 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -108,6 +108,7 @@ #include "scene/animation/animation_player.h" #include "scene/animation/animation_tree_player.h" +#include "scene/animation/tween.h" #include "scene/main/scene_main_loop.h" #include "scene/main/resource_preloader.h" #include "scene/resources/packed_scene.h" @@ -369,6 +370,7 @@ void register_scene_types() { ObjectTypeDB::register_type(); ObjectTypeDB::register_type(); ObjectTypeDB::register_type(); + ObjectTypeDB::register_type(); OS::get_singleton()->yield(); //may take time to init -- cgit v1.2.3 From b51da466e9fc25fb39e499f1d521a2a0b78c63cf Mon Sep 17 00:00:00 2001 From: sanikoyes Date: Wed, 20 Aug 2014 12:19:22 +0800 Subject: 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 e7876e3bfa..eebb0d6777 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 9d087f93ca..5a8186cc21 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 -- cgit v1.2.3 From 87faf1c046ddc024cf956096f8ad342b97f3c2d4 Mon Sep 17 00:00:00 2001 From: sanikoyes Date: Wed, 20 Aug 2014 16:39:28 +0800 Subject: Add tween seek/repeat support Add tween demo --- demos/misc/tween/engine.cfg | 10 ++ demos/misc/tween/main.gd | 127 +++++++++++++++++ demos/misc/tween/main.xml | 332 ++++++++++++++++++++++++++++++++++++++++++++ scene/animation/tween.cpp | 54 ++++++- scene/animation/tween.h | 6 + 5 files changed, 525 insertions(+), 4 deletions(-) create mode 100644 demos/misc/tween/engine.cfg create mode 100644 demos/misc/tween/main.gd create mode 100644 demos/misc/tween/main.xml diff --git a/demos/misc/tween/engine.cfg b/demos/misc/tween/engine.cfg new file mode 100644 index 0000000000..7966a56830 --- /dev/null +++ b/demos/misc/tween/engine.cfg @@ -0,0 +1,10 @@ +[application] + +name="Tween Demo" +main_scene="res://main.xml" +icon="icon.png" + +[display] + +stretch_mode="2d" +stretch_aspect="keep_width" diff --git a/demos/misc/tween/main.gd b/demos/misc/tween/main.gd new file mode 100644 index 0000000000..5f6828f6f4 --- /dev/null +++ b/demos/misc/tween/main.gd @@ -0,0 +1,127 @@ + +extends Control + +# member variables here, example: +# var a=2 +# var b="textvar" + +var trans = ["linear", "sine", "quint", "quart", "quad", "expo", "elastic", "cubic", "circ", "bounce", "back"] +var eases = ["in", "out", "in_out", "out_in"] +var modes = ["move", "color", "scale", "rotate", "repeat", "pause"] + +var state = { + trans = Tween.TRANS_LINEAR, + eases = Tween.EASE_IN, +} + +func _ready(): + for index in range(trans.size()): + var name = trans[index] + get_node("trans/" + name).connect("pressed", self, "on_trans_changed", [name, index]) + + for index in range(eases.size()): + var name = eases[index] + get_node("eases/" + name).connect("pressed", self, "on_eases_changed", [name, index]) + + for index in range(modes.size()): + var name = modes[index] + get_node("modes/" + name).connect("pressed", self, "on_modes_changed", [name]) + + get_node("color/color_from").set_color(Color(1, 0, 0, 1)) + get_node("color/color_from").connect("color_changed", self, "on_color_changed") + + get_node("color/color_to").set_color(Color(0, 1, 1, 1)) + get_node("color/color_to").connect("color_changed", self, "on_color_changed") + + get_node("trans/linear").set_pressed(true) + get_node("eases/in").set_pressed(true) + get_node("modes/move").set_pressed(true) + get_node("modes/repeat").set_pressed(true) + + reset_tween() + + # Initalization here + pass + +func on_trans_changed(name, index): + for index in range(trans.size()): + var pressed = trans[index] == name + var btn = get_node("trans/" + trans[index]) + + btn.set_pressed(pressed) + btn.set_ignore_mouse(pressed) + + state.trans = index + reset_tween() + +func on_eases_changed(name, index): + for index in range(eases.size()): + var pressed = eases[index] == name + var btn = get_node("eases/" + eases[index]) + + btn.set_pressed(pressed) + btn.set_ignore_mouse(pressed) + + state.eases = index + reset_tween() + +func on_modes_changed(name): + var tween = get_node("tween") + if name == "pause": + if get_node("modes/pause").is_pressed(): + tween.stop_all() + get_node("timeline").show() + else: + tween.resume_all() + get_node("timeline").hide() + else: + reset_tween() + +func on_color_changed(color): + reset_tween() + +func reset_tween(): + var tween = get_node("tween") + tween.reset_all() + tween.remove_all() + + var sprite = get_node("tween/area/sprite") + + if get_node("modes/move").is_pressed(): + tween.interpolate_method(sprite, "set_pos", Vector2(0,0), Vector2(736, 184), 2, state.trans, state.eases) + + if get_node("modes/color").is_pressed(): + tween.interpolate_method(sprite, "set_modulate", get_node("color/color_from").get_color(), get_node("color/color_to").get_color(), 2, state.trans, state.eases) + else: + sprite.set_modulate(Color(1, 1, 1, 1)) + + if get_node("modes/scale").is_pressed(): + tween.interpolate_method(sprite, "set_scale", Vector2(0.5,0.5), Vector2(1.5, 1.5), 2, state.trans, state.eases) + + if get_node("modes/rotate").is_pressed(): + tween.interpolate_method(sprite, "set_rot", 0.0, 6.28, 2, state.trans, state.eases) + + tween.set_repeat(get_node("modes/repeat").is_pressed()) + tween.start() + + if get_node("modes/pause").is_pressed(): + tween.stop_all() + get_node("timeline").show() + get_node("timeline").set_value(0) + else: + tween.resume_all() + get_node("timeline").hide() + +func _on_tween_step( object, key, elapsed, value ): + var timeline = get_node("timeline") + var ratio = 100 * (elapsed / 2) + timeline.set_value(ratio) + + +func _on_timeline_value_changed( value ): + if !get_node("modes/pause").is_pressed(): + return + + var tween = get_node("tween") + tween.seek(2.0 * value / 100) + diff --git a/demos/misc/tween/main.xml b/demos/misc/tween/main.xml new file mode 100644 index 0000000000..8c6c9c4639 --- /dev/null +++ b/demos/misc/tween/main.xml @@ -0,0 +1,332 @@ + + + + + + + "names" + + "main" + "Control" + "_import_path" + "visibility/visible" + "visibility/opacity" + "visibility/self_opacity" + "visibility/behind_parent" + "margin/right" + "margin/bottom" + "transform/rot" + "transform/scale" + "focus_neighbour/left" + "focus_neighbour/top" + "focus_neighbour/right" + "focus_neighbour/bottom" + "focus/ignore_mouse" + "focus/stop_mouse" + "size_flags/horizontal" + "size_flags/vertical" + "size_flags/stretch_ratio" + "script/script" + "__meta__" + "trans" + "VBoxContainer" + "margin/left" + "margin/top" + "linear" + "Button" + "disabled" + "pressed" + "toggle_mode" + "click_on_press" + "text" + "icon" + "flat" + "clip_text" + "align" + "sine" + "quint" + "quart" + "quad" + "expo" + "elastic" + "cubic" + "circ" + "bounce" + "back" + "eases" + "in" + "out" + "in_out" + "out_in" + "modes" + "move" + "color" + "scale" + "rotate" + "repeat" + "pause" + "label_1" + "Label" + "range/min" + "range/max" + "range/step" + "range/page" + "range/value" + "range/exp_edit" + "rounded_values" + "valign" + "autowrap" + "uppercase" + "percent_visible" + "color_from" + "ColorPicker" + "label_2" + "color_to" + "tween" + "Tween" + "playback/active" + "playback/repeat" + "playback/speed" + "area" + "Panel" + "sprite" + "Sprite" + "transform/pos" + "texture" + "centered" + "offset" + "flip_h" + "flip_v" + "vframes" + "hframes" + "frame" + "modulate" + "region" + "region_rect" + "timeline" + "HSlider" + "tick_count" + "ticks_on_borders" + "_on_tween_step" + "tween_step" + "_on_timeline_value_changed" + "value_changed" + + "version" + 1 + "conn_count" + 2 + "node_count" + 34 + "variants" + + "" + True + 1 + False + 800 + 600 + 0 + 1, 1 + 2 + + + "__editor_plugin_states__" + + "Script" + + "current" + 0 + "sources" + + "res://main.gd" + + + "2D" + + "pixel_snap" + False + "zoom" + 1.360374 + "use_snap" + True + "ofs" + -220.639, 36.0825 + "snap" + 8 + + "3D" + + "zfar" + 500 + "fov" + 45 + "viewports" + + + "distance" + 4 + "x_rot" + 0 + "y_rot" + 0 + "use_orthogonal" + False + "use_environment" + False + "pos" + 0, 0, 0 + + + "distance" + 4 + "x_rot" + 0 + "y_rot" + 0 + "use_orthogonal" + False + "use_environment" + False + "pos" + 0, 0, 0 + + + "distance" + 4 + "x_rot" + 0 + "y_rot" + 0 + "use_orthogonal" + False + "use_environment" + False + "pos" + 0, 0, 0 + + + "distance" + 4 + "x_rot" + 0 + "y_rot" + 0 + "use_orthogonal" + False + "use_environment" + False + "pos" + 0, 0, 0 + + + "viewport_mode" + 1 + "default_light" + True + "show_grid" + True + "show_origin" + True + "znear" + 0.1 + + + "__editor_run_settings__" + + "custom_args" + "-l $scene" + "run_mode" + 0 + + "__editor_plugin_screen__" + "Script" + + 56 + 256 + 129 + 582 + 73 + 26 + "linear" + 1 + 30 + "sine" + 60 + 86 + "quint" + 90 + 116 + "quart" + 120 + 146 + "quad" + 150 + 176 + "expo" + 180 + 206 + "elastic" + 210 + 236 + "cubic" + 240 + 266 + "circ" + 270 + 296 + "bounce" + 300 + 326 + "back" + 152 + 215 + 372 + 63 + "in" + "out" + "in_out" + "out_in" + 305 + 402 + 65 + "move" + "color" + "scale" + "rotate" + "repeat" + "pause" + 384 + 760 + 592 + 376 + 19 + "Color From:" + 0 + -1 + 23 + 174 + 178 + 197 + "Color To:" + 201 + 352 + 32 + 768 + 216 + 0, 0 + + 1, 1, 1, 1 + 0, 0, 0, 0 + 40 + 224 + 100 + + "nodes" + -1, -1, 1, 0, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 20, 9, 21, 10, 0, 0, 0, 23, 22, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 11, 25, 12, 7, 13, 8, 14, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 1, 0, 27, 26, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 15, 8, 16, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 17, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 37, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 20, 7, 15, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 21, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 38, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 22, 7, 15, 8, 23, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 24, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 39, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 25, 7, 15, 8, 26, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 27, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 40, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 28, 7, 15, 8, 29, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 30, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 41, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 31, 7, 15, 8, 32, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 33, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 42, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 34, 7, 15, 8, 35, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 36, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 43, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 37, 7, 15, 8, 38, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 39, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 44, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 40, 7, 15, 8, 41, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 42, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 45, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 43, 7, 15, 8, 44, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 45, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 46, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 46, 7, 15, 8, 47, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 48, 33, 18, 34, 3, 35, 3, 36, 19, 0, 0, 0, 23, 47, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 49, 25, 12, 7, 50, 8, 51, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 13, 0, 27, 48, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 52, 8, 16, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 53, 33, 18, 34, 3, 35, 3, 36, 19, 0, 13, 0, 27, 49, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 20, 7, 52, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 54, 33, 18, 34, 3, 35, 3, 36, 19, 0, 13, 0, 27, 50, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 22, 7, 52, 8, 23, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 55, 33, 18, 34, 3, 35, 3, 36, 19, 0, 13, 0, 27, 51, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 25, 7, 52, 8, 26, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 56, 33, 18, 34, 3, 35, 3, 36, 19, 0, 0, 0, 23, 52, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 40, 25, 12, 7, 57, 8, 58, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 18, 0, 27, 53, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 59, 8, 16, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 60, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 54, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 20, 7, 59, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 61, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 55, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 22, 7, 59, 8, 23, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 62, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 56, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 25, 7, 59, 8, 26, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 63, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 57, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 28, 7, 59, 8, 29, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 64, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 58, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 31, 7, 59, 8, 32, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 65, 33, 18, 34, 3, 35, 3, 36, 19, 0, 0, 0, 23, 54, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 66, 25, 40, 7, 67, 8, 68, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 25, 0, 60, 59, -1, 30, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 69, 8, 70, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 1, 16, 1, 17, 8, 19, 2, 61, 6, 62, 2, 63, 2, 64, 2, 65, 6, 66, 3, 67, 3, 32, 71, 36, 72, 68, 72, 69, 3, 70, 3, 71, 73, 0, 25, 0, 73, 72, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 74, 7, 69, 8, 75, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 25, 0, 60, 74, -1, 31, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 76, 7, 69, 8, 77, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 1, 16, 1, 17, 8, 19, 2, 61, 6, 62, 2, 63, 2, 64, 2, 65, 6, 66, 3, 67, 3, 32, 78, 36, 72, 68, 72, 69, 3, 70, 3, 71, 73, 0, 25, 0, 73, 75, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 79, 7, 69, 8, 80, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 0, 0, 77, 76, -1, 4, 2, 0, 78, 1, 79, 1, 80, 2, 0, 30, 0, 82, 81, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 81, 25, 81, 7, 82, 8, 83, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 0, 31, 0, 84, 83, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 85, 84, 9, 6, 10, 7, 86, 85, 87, 1, 88, 84, 89, 3, 90, 3, 91, 19, 92, 19, 93, 72, 94, 86, 95, 3, 96, 87, 0, 0, 0, 98, 97, -1, 28, 2, 0, 3, 3, 4, 2, 5, 2, 6, 3, 24, 88, 25, 89, 7, 67, 8, 40, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 19, 2, 61, 6, 62, 90, 63, 2, 64, 6, 65, 2, 66, 3, 67, 3, 99, 72, 100, 3, 0 + "conns" + 30, 0, 102, 101, 2, 0, 33, 0, 104, 103, 2, 0 + + + + diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index eebb0d6777..305e105fdd 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -37,6 +37,10 @@ bool Tween::_set(const StringName& p_name, const Variant& p_value) { } else if (name=="playback/active") { set_active(p_value); + + } else if (name=="playback/repeat") { + set_repeat(p_value); + } return true; } @@ -51,13 +55,18 @@ bool Tween::_get(const StringName& p_name,Variant &r_ret) const { } else if (name=="playback/active") { r_ret=is_active(); + } else if(name=="playback/repeat") { + + r_ret=is_repeat(); } + return true; } void Tween::_get_property_list(List *p_list) const { p_list->push_back( PropertyInfo( Variant::BOOL, "playback/active", PROPERTY_HINT_NONE,"" ) ); + p_list->push_back( PropertyInfo( Variant::BOOL, "playback/repeat", PROPERTY_HINT_NONE,"" ) ); p_list->push_back( PropertyInfo( Variant::REAL, "playback/speed", PROPERTY_HINT_RANGE, "-64,64,0.01") ); } @@ -104,6 +113,9 @@ void Tween::_bind_methods() { ObjectTypeDB::bind_method(_MD("is_active"),&Tween::is_active ); ObjectTypeDB::bind_method(_MD("set_active","active"),&Tween::set_active ); + ObjectTypeDB::bind_method(_MD("is_repeat"),&Tween::is_repeat ); + ObjectTypeDB::bind_method(_MD("set_repeat","repeat"),&Tween::set_repeat ); + ObjectTypeDB::bind_method(_MD("set_speed","speed"),&Tween::set_speed); ObjectTypeDB::bind_method(_MD("get_speed"),&Tween::get_speed); @@ -119,13 +131,14 @@ void Tween::_bind_methods() { 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("seek"),&Tween::seek ); 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 ); ADD_SIGNAL( MethodInfo("tween_start", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key")) ); - ADD_SIGNAL( MethodInfo("tween_step", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key"), PropertyInfo( Variant::OBJECT,"value")) ); - ADD_SIGNAL( MethodInfo("tween_complete", PropertyInfo( Variant::INT,"id")) ); + ADD_SIGNAL( MethodInfo("tween_step", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key"), PropertyInfo( Variant::REAL,"elapsed"), PropertyInfo( Variant::OBJECT,"value")) ); + ADD_SIGNAL( MethodInfo("tween_complete", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key")) ); //ADD_PROPERTY( PropertyInfo( Variant::BOOL, "activate"), _SCS("set_active"), _SCS("is_active")); @@ -334,8 +347,14 @@ void Tween::_tween_process(float p_delta) { for(List::Element *E=interpolates.front();E;E=E->next()) { InterpolateData& data = E->get(); - if(!data.active || data.elapsed == data.times_in_sec) + if(!data.active) continue; + if(data.elapsed == data.times_in_sec) { + + if(!repeat) + continue; + data.elapsed = 0; + } if(data.elapsed == 0) emit_signal("tween_start",data.object,data.key); @@ -345,7 +364,7 @@ void Tween::_tween_process(float p_delta) { data.elapsed = data.times_in_sec; Variant result = _run_equation(data); - emit_signal("tween_step",data.object,data.key,result); + emit_signal("tween_step",data.object,data.key,data.elapsed,result); _apply_tween_value(data, result); @@ -400,6 +419,16 @@ void Tween::set_active(bool p_active) { _set_process(processing,true); } +bool Tween::is_repeat() const { + + return repeat; +} + +void Tween::set_repeat(bool p_repeat) { + + repeat = p_repeat; +} + void Tween::set_speed(float p_speed) { speed_scale=p_speed; @@ -511,6 +540,22 @@ bool Tween::remove_all() { return true; } +bool Tween::seek(real_t p_time) { + + for(List::Element *E=interpolates.front();E;E=E->next()) { + + InterpolateData& data = E->get(); + + data.elapsed = p_time; + if(data.elapsed > data.times_in_sec) + data.elapsed = data.times_in_sec; + + Variant result = _run_equation(data); + + _apply_tween_value(data, result); + } + return true; +} bool Tween::_calc_delta_val(InterpolateData& p_data) { @@ -703,6 +748,7 @@ Tween::Tween() { tween_process_mode=TWEEN_PROCESS_IDLE; processing=false; active=false; + repeat=false; speed_scale=1; } diff --git a/scene/animation/tween.h b/scene/animation/tween.h index 5a8186cc21..7dd917dc8e 100644 --- a/scene/animation/tween.h +++ b/scene/animation/tween.h @@ -88,6 +88,7 @@ private: TweenProcessMode tween_process_mode; bool processing; bool active; + bool repeat; float speed_scale; List interpolates; @@ -117,6 +118,9 @@ public: bool is_active() const; void set_active(bool p_active); + bool is_repeat() const; + void set_repeat(bool p_repeat); + void set_tween_process_mode(TweenProcessMode p_mode); TweenProcessMode get_tween_process_mode() const; @@ -133,6 +137,8 @@ public: bool remove(Variant p_object, String p_key); bool remove_all(); + bool seek(real_t p_time); + bool interpolate_property(Variant p_object , String p_property , Variant p_initial_val -- cgit v1.2.3 From 1c0ac4ee45bf197152bc2bd6cf436a155b72f309 Mon Sep 17 00:00:00 2001 From: sanikoyes Date: Wed, 20 Aug 2014 18:33:17 +0800 Subject: Add missing bind, fix bind argument description --- scene/animation/tween.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 305e105fdd..cdd9176a1b 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -123,13 +123,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 ); 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 ); ObjectTypeDB::bind_method(_MD("stop_all"),&Tween::stop_all ); - ObjectTypeDB::bind_method(_MD("resume"),&Tween::resume ); + ObjectTypeDB::bind_method(_MD("resume","object","key"),&Tween::resume ); ObjectTypeDB::bind_method(_MD("resume_all"),&Tween::resume_all ); - ObjectTypeDB::bind_method(_MD("remove"),&Tween::remove ); + ObjectTypeDB::bind_method(_MD("remove","object","key"),&Tween::remove ); ObjectTypeDB::bind_method(_MD("remove_all"),&Tween::remove_all ); ObjectTypeDB::bind_method(_MD("seek"),&Tween::seek ); @@ -140,6 +140,7 @@ void Tween::_bind_methods() { ADD_SIGNAL( MethodInfo("tween_step", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key"), PropertyInfo( Variant::REAL,"elapsed"), PropertyInfo( Variant::OBJECT,"value")) ); ADD_SIGNAL( MethodInfo("tween_complete", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key")) ); + ADD_PROPERTY( PropertyInfo( Variant::INT, "playback/process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_tween_process_mode"), _SCS("get_tween_process_mode")); //ADD_PROPERTY( PropertyInfo( Variant::BOOL, "activate"), _SCS("set_active"), _SCS("is_active")); BIND_CONSTANT(TRANS_LINEAR); -- cgit v1.2.3 From 5668cec030e67a89994a97db06ca7101ab9be272 Mon Sep 17 00:00:00 2001 From: sanikoyes Date: Thu, 21 Aug 2014 15:34:16 +0800 Subject: Add tween delay support Add tween get_runtime function Update demo for tween delay sample --- demos/misc/tween/main.gd | 15 ++++++++-- demos/misc/tween/main.xml | 11 +++---- scene/animation/tween.cpp | 75 ++++++++++++++++++++++++++++++++++++++--------- scene/animation/tween.h | 5 ++++ 4 files changed, 84 insertions(+), 22 deletions(-) diff --git a/demos/misc/tween/main.gd b/demos/misc/tween/main.gd index 5f6828f6f4..002e720e79 100644 --- a/demos/misc/tween/main.gd +++ b/demos/misc/tween/main.gd @@ -89,17 +89,21 @@ func reset_tween(): if get_node("modes/move").is_pressed(): tween.interpolate_method(sprite, "set_pos", Vector2(0,0), Vector2(736, 184), 2, state.trans, state.eases) + tween.interpolate_method(sprite, "set_pos", Vector2(736,184), Vector2(0, 0), 2, state.trans, state.eases, 2) if get_node("modes/color").is_pressed(): tween.interpolate_method(sprite, "set_modulate", get_node("color/color_from").get_color(), get_node("color/color_to").get_color(), 2, state.trans, state.eases) + tween.interpolate_method(sprite, "set_modulate", get_node("color/color_to").get_color(), get_node("color/color_from").get_color(), 2, state.trans, state.eases, 2) else: sprite.set_modulate(Color(1, 1, 1, 1)) if get_node("modes/scale").is_pressed(): tween.interpolate_method(sprite, "set_scale", Vector2(0.5,0.5), Vector2(1.5, 1.5), 2, state.trans, state.eases) + tween.interpolate_method(sprite, "set_scale", Vector2(1.5,1.5), Vector2(0.5, 0.5), 2, state.trans, state.eases, 2) if get_node("modes/rotate").is_pressed(): - tween.interpolate_method(sprite, "set_rot", 0.0, 6.28, 2, state.trans, state.eases) + tween.interpolate_method(sprite, "set_rot", 0, 6.28, 2, state.trans, state.eases) + tween.interpolate_method(sprite, "set_rot", 6.28, 0, 2, state.trans, state.eases, 2) tween.set_repeat(get_node("modes/repeat").is_pressed()) tween.start() @@ -114,7 +118,11 @@ func reset_tween(): func _on_tween_step( object, key, elapsed, value ): var timeline = get_node("timeline") - var ratio = 100 * (elapsed / 2) + + var tween = get_node("tween") + var runtime = tween.get_runtime() + + var ratio = 100 * (elapsed / runtime) timeline.set_value(ratio) @@ -123,5 +131,6 @@ func _on_timeline_value_changed( value ): return var tween = get_node("tween") - tween.seek(2.0 * value / 100) + var runtime = tween.get_runtime() + tween.seek(runtime * value / 100) diff --git a/demos/misc/tween/main.xml b/demos/misc/tween/main.xml index 8c6c9c4639..f403937818 100644 --- a/demos/misc/tween/main.xml +++ b/demos/misc/tween/main.xml @@ -5,7 +5,7 @@ "names" - + "main" "Control" "_import_path" @@ -84,6 +84,7 @@ "color_to" "tween" "Tween" + "playback/process_mode" "playback/active" "playback/repeat" "playback/speed" @@ -147,11 +148,11 @@ "pixel_snap" False "zoom" - 1.360374 + 1.227738 "use_snap" True "ofs" - -220.639, 36.0825 + -319.009, -56.3619 "snap" 8 @@ -323,9 +324,9 @@ 100 "nodes" - -1, -1, 1, 0, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 20, 9, 21, 10, 0, 0, 0, 23, 22, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 11, 25, 12, 7, 13, 8, 14, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 1, 0, 27, 26, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 15, 8, 16, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 17, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 37, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 20, 7, 15, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 21, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 38, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 22, 7, 15, 8, 23, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 24, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 39, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 25, 7, 15, 8, 26, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 27, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 40, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 28, 7, 15, 8, 29, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 30, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 41, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 31, 7, 15, 8, 32, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 33, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 42, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 34, 7, 15, 8, 35, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 36, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 43, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 37, 7, 15, 8, 38, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 39, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 44, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 40, 7, 15, 8, 41, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 42, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 45, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 43, 7, 15, 8, 44, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 45, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 46, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 46, 7, 15, 8, 47, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 48, 33, 18, 34, 3, 35, 3, 36, 19, 0, 0, 0, 23, 47, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 49, 25, 12, 7, 50, 8, 51, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 13, 0, 27, 48, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 52, 8, 16, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 53, 33, 18, 34, 3, 35, 3, 36, 19, 0, 13, 0, 27, 49, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 20, 7, 52, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 54, 33, 18, 34, 3, 35, 3, 36, 19, 0, 13, 0, 27, 50, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 22, 7, 52, 8, 23, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 55, 33, 18, 34, 3, 35, 3, 36, 19, 0, 13, 0, 27, 51, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 25, 7, 52, 8, 26, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 56, 33, 18, 34, 3, 35, 3, 36, 19, 0, 0, 0, 23, 52, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 40, 25, 12, 7, 57, 8, 58, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 18, 0, 27, 53, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 59, 8, 16, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 60, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 54, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 20, 7, 59, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 61, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 55, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 22, 7, 59, 8, 23, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 62, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 56, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 25, 7, 59, 8, 26, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 63, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 57, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 28, 7, 59, 8, 29, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 64, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 58, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 31, 7, 59, 8, 32, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 65, 33, 18, 34, 3, 35, 3, 36, 19, 0, 0, 0, 23, 54, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 66, 25, 40, 7, 67, 8, 68, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 25, 0, 60, 59, -1, 30, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 69, 8, 70, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 1, 16, 1, 17, 8, 19, 2, 61, 6, 62, 2, 63, 2, 64, 2, 65, 6, 66, 3, 67, 3, 32, 71, 36, 72, 68, 72, 69, 3, 70, 3, 71, 73, 0, 25, 0, 73, 72, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 74, 7, 69, 8, 75, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 25, 0, 60, 74, -1, 31, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 76, 7, 69, 8, 77, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 1, 16, 1, 17, 8, 19, 2, 61, 6, 62, 2, 63, 2, 64, 2, 65, 6, 66, 3, 67, 3, 32, 78, 36, 72, 68, 72, 69, 3, 70, 3, 71, 73, 0, 25, 0, 73, 75, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 79, 7, 69, 8, 80, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 0, 0, 77, 76, -1, 4, 2, 0, 78, 1, 79, 1, 80, 2, 0, 30, 0, 82, 81, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 81, 25, 81, 7, 82, 8, 83, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 0, 31, 0, 84, 83, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 85, 84, 9, 6, 10, 7, 86, 85, 87, 1, 88, 84, 89, 3, 90, 3, 91, 19, 92, 19, 93, 72, 94, 86, 95, 3, 96, 87, 0, 0, 0, 98, 97, -1, 28, 2, 0, 3, 3, 4, 2, 5, 2, 6, 3, 24, 88, 25, 89, 7, 67, 8, 40, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 19, 2, 61, 6, 62, 90, 63, 2, 64, 6, 65, 2, 66, 3, 67, 3, 99, 72, 100, 3, 0 + -1, -1, 1, 0, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 20, 9, 21, 10, 0, 0, 0, 23, 22, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 11, 25, 12, 7, 13, 8, 14, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 1, 0, 27, 26, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 15, 8, 16, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 17, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 37, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 20, 7, 15, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 21, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 38, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 22, 7, 15, 8, 23, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 24, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 39, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 25, 7, 15, 8, 26, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 27, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 40, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 28, 7, 15, 8, 29, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 30, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 41, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 31, 7, 15, 8, 32, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 33, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 42, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 34, 7, 15, 8, 35, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 36, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 43, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 37, 7, 15, 8, 38, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 39, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 44, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 40, 7, 15, 8, 41, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 42, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 45, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 43, 7, 15, 8, 44, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 45, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 46, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 46, 7, 15, 8, 47, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 48, 33, 18, 34, 3, 35, 3, 36, 19, 0, 0, 0, 23, 47, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 49, 25, 12, 7, 50, 8, 51, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 13, 0, 27, 48, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 52, 8, 16, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 53, 33, 18, 34, 3, 35, 3, 36, 19, 0, 13, 0, 27, 49, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 20, 7, 52, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 54, 33, 18, 34, 3, 35, 3, 36, 19, 0, 13, 0, 27, 50, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 22, 7, 52, 8, 23, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 55, 33, 18, 34, 3, 35, 3, 36, 19, 0, 13, 0, 27, 51, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 25, 7, 52, 8, 26, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 56, 33, 18, 34, 3, 35, 3, 36, 19, 0, 0, 0, 23, 52, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 40, 25, 12, 7, 57, 8, 58, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 18, 0, 27, 53, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 59, 8, 16, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 60, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 54, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 20, 7, 59, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 61, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 55, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 22, 7, 59, 8, 23, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 62, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 56, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 25, 7, 59, 8, 26, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 63, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 57, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 28, 7, 59, 8, 29, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 64, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 58, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 31, 7, 59, 8, 32, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 65, 33, 18, 34, 3, 35, 3, 36, 19, 0, 0, 0, 23, 54, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 66, 25, 40, 7, 67, 8, 68, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 25, 0, 60, 59, -1, 30, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 69, 8, 70, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 1, 16, 1, 17, 8, 19, 2, 61, 6, 62, 2, 63, 2, 64, 2, 65, 6, 66, 3, 67, 3, 32, 71, 36, 72, 68, 72, 69, 3, 70, 3, 71, 73, 0, 25, 0, 73, 72, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 74, 7, 69, 8, 75, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 25, 0, 60, 74, -1, 31, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 76, 7, 69, 8, 77, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 1, 16, 1, 17, 8, 19, 2, 61, 6, 62, 2, 63, 2, 64, 2, 65, 6, 66, 3, 67, 3, 32, 78, 36, 72, 68, 72, 69, 3, 70, 3, 71, 73, 0, 25, 0, 73, 75, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 79, 7, 69, 8, 80, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 0, 0, 77, 76, -1, 5, 2, 0, 78, 19, 79, 1, 80, 1, 81, 2, 0, 30, 0, 83, 82, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 81, 25, 81, 7, 82, 8, 83, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 0, 31, 0, 85, 84, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 86, 84, 9, 6, 10, 7, 87, 85, 88, 1, 89, 84, 90, 3, 91, 3, 92, 19, 93, 19, 94, 72, 95, 86, 96, 3, 97, 87, 0, 0, 0, 99, 98, -1, 28, 2, 0, 3, 3, 4, 2, 5, 2, 6, 3, 24, 88, 25, 89, 7, 67, 8, 40, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 19, 2, 61, 6, 62, 90, 63, 2, 64, 6, 65, 2, 66, 3, 67, 3, 100, 72, 101, 3, 0 "conns" - 30, 0, 102, 101, 2, 0, 33, 0, 104, 103, 2, 0 + 30, 0, 103, 102, 2, 0, 33, 0, 105, 104, 2, 0 diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index cdd9176a1b..48a2fd564b 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -132,9 +132,10 @@ void Tween::_bind_methods() { ObjectTypeDB::bind_method(_MD("remove","object","key"),&Tween::remove ); ObjectTypeDB::bind_method(_MD("remove_all"),&Tween::remove_all ); ObjectTypeDB::bind_method(_MD("seek"),&Tween::seek ); + ObjectTypeDB::bind_method(_MD("get_runtime"),&Tween::get_runtime ); - 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 ); + ObjectTypeDB::bind_method(_MD("interpolate_property","object","property","initial_val","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::interpolate_property, DEFVAL(0) ); + ObjectTypeDB::bind_method(_MD("interpolate_method","object","method","initial_val","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::interpolate_method, DEFVAL(0) ); ADD_SIGNAL( MethodInfo("tween_start", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key")) ); ADD_SIGNAL( MethodInfo("tween_step", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key"), PropertyInfo( Variant::REAL,"elapsed"), PropertyInfo( Variant::OBJECT,"value")) ); @@ -168,16 +169,16 @@ Variant Tween::_run_equation(InterpolateData& p_data) { Variant result; #define APPLY_EQUATION(element)\ - r.element = _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed, i.element, d.element, p_data.times_in_sec); + r.element = _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, i.element, d.element, p_data.times_in_sec); switch(initial_val.get_type()) { case Variant::INT: - result = (int) _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed, (int) initial_val, (int) delta_val, p_data.times_in_sec); + result = (int) _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, (int) initial_val, (int) delta_val, p_data.times_in_sec); break; case Variant::REAL: - result = _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed, (real_t) initial_val, (real_t) delta_val, p_data.times_in_sec); + result = _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, (real_t) initial_val, (real_t) delta_val, p_data.times_in_sec); break; case Variant::VECTOR2: @@ -350,26 +351,33 @@ void Tween::_tween_process(float p_delta) { InterpolateData& data = E->get(); if(!data.active) continue; - if(data.elapsed == data.times_in_sec) { + if(data.finish) { if(!repeat) continue; data.elapsed = 0; + data.finish = false; } - if(data.elapsed == 0) + bool prev_delaying = data.elapsed <= data.delay; + data.elapsed += p_delta; + if(data.elapsed < data.delay) + continue; + else if(prev_delaying) emit_signal("tween_start",data.object,data.key); - data.elapsed += p_delta; - if(data.elapsed > data.times_in_sec) - data.elapsed = data.times_in_sec; + if(data.elapsed > (data.delay + data.times_in_sec)) { + + data.elapsed = data.delay + data.times_in_sec; + data.finish = true; + } Variant result = _run_equation(data); emit_signal("tween_step",data.object,data.key,data.elapsed,result); _apply_tween_value(data, result); - if(data.elapsed == data.times_in_sec) + if(data.finish) emit_signal("tween_complete",data.object,data.key); } } @@ -452,8 +460,12 @@ bool Tween::reset(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) + if(data.object == p_object && data.key == p_key) { + + data.elapsed = 0; + data.finish = false; _apply_tween_value(data, data.initial_val); + } } return true; } @@ -463,6 +475,8 @@ bool Tween::reset_all() { for(List::Element *E=interpolates.front();E;E=E->next()) { InterpolateData& data = E->get(); + data.elapsed = 0; + data.finish = false; _apply_tween_value(data, data.initial_val); } return true; @@ -548,8 +562,10 @@ bool Tween::seek(real_t p_time) { InterpolateData& data = E->get(); data.elapsed = p_time; - if(data.elapsed > data.times_in_sec) - data.elapsed = data.times_in_sec; + if(data.elapsed < data.delay) + continue; + else if(data.elapsed > (data.delay + data.times_in_sec)) + data.elapsed = (data.delay + data.times_in_sec); Variant result = _run_equation(data); @@ -558,6 +574,19 @@ bool Tween::seek(real_t p_time) { return true; } +real_t Tween::get_runtime() { + + real_t runtime = 0; + for(List::Element *E=interpolates.front();E;E=E->next()) { + + InterpolateData& data = E->get(); + real_t t = data.delay + data.times_in_sec; + if(t > runtime) + runtime = t; + } + return runtime; +} + bool Tween::_calc_delta_val(InterpolateData& p_data) { Variant& initial_val = p_data.initial_val; @@ -666,11 +695,18 @@ bool Tween::interpolate_property(Variant p_object , real_t p_times_in_sec , TransitionType p_trans_type , EaseType p_ease_type + , real_t p_delay ) { + // convert INT to REAL is better for interpolaters + if(p_initial_val.get_type() == Variant::INT) p_initial_val = p_initial_val.operator real_t(); + if(p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t(); ERR_FAIL_COND_V(p_object.get_type() != Variant::OBJECT, false); ERR_FAIL_COND_V(p_initial_val.get_type() != p_final_val.get_type(), false); ERR_FAIL_COND_V(p_times_in_sec <= 0, false); + ERR_FAIL_COND_V(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, false); + ERR_FAIL_COND_V(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false); + ERR_FAIL_COND_V(p_delay < 0, false); bool prop_found = false; Object *obj = (Object *) p_object; @@ -690,6 +726,7 @@ bool Tween::interpolate_property(Variant p_object InterpolateData data; data.active = true; data.is_method = false; + data.finish = false; data.elapsed = 0; data.object = p_object; @@ -699,6 +736,7 @@ bool Tween::interpolate_property(Variant p_object data.times_in_sec = p_times_in_sec; data.trans_type = p_trans_type; data.ease_type = p_ease_type; + data.delay = p_delay; if(!_calc_delta_val(data)) return false; @@ -714,11 +752,18 @@ bool Tween::interpolate_method(Variant p_object , real_t p_times_in_sec , TransitionType p_trans_type , EaseType p_ease_type + , real_t p_delay ) { + // convert INT to REAL is better for interpolaters + if(p_initial_val.get_type() == Variant::INT) p_initial_val = p_initial_val.operator real_t(); + if(p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t(); ERR_FAIL_COND_V(p_object.get_type() != Variant::OBJECT, false); ERR_FAIL_COND_V(p_initial_val.get_type() != p_final_val.get_type(), false); ERR_FAIL_COND_V(p_times_in_sec <= 0, false); + ERR_FAIL_COND_V(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, false); + ERR_FAIL_COND_V(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false); + ERR_FAIL_COND_V(p_delay < 0, false); Object *obj = (Object *) p_object; ERR_FAIL_COND_V(!obj->has_method(p_method), false); @@ -726,6 +771,7 @@ bool Tween::interpolate_method(Variant p_object InterpolateData data; data.active = true; data.is_method = true; + data.finish = false; data.elapsed = 0; data.object = p_object; @@ -735,6 +781,7 @@ bool Tween::interpolate_method(Variant p_object data.times_in_sec = p_times_in_sec; data.trans_type = p_trans_type; data.ease_type = p_ease_type; + data.delay = p_delay; if(!_calc_delta_val(data)) return false; diff --git a/scene/animation/tween.h b/scene/animation/tween.h index 7dd917dc8e..78df7d9c93 100644 --- a/scene/animation/tween.h +++ b/scene/animation/tween.h @@ -72,6 +72,7 @@ private: struct InterpolateData { bool active; bool is_method; + bool finish; real_t elapsed; Variant object; @@ -82,6 +83,7 @@ private: real_t times_in_sec; TransitionType trans_type; EaseType ease_type; + real_t delay; }; String autoplay; @@ -138,6 +140,7 @@ public: bool remove_all(); bool seek(real_t p_time); + real_t get_runtime(); bool interpolate_property(Variant p_object , String p_property @@ -146,6 +149,7 @@ public: , real_t p_times_in_sec , TransitionType p_trans_type , EaseType p_ease_type + , real_t p_delay = 0 ); bool interpolate_method(Variant p_object @@ -155,6 +159,7 @@ public: , real_t p_times_in_sec , TransitionType p_trans_type , EaseType p_ease_type + , real_t p_delay = 0 ); Tween(); -- cgit v1.2.3 From d7eb4550b0d33d3b932c166d2216a4c468d49649 Mon Sep 17 00:00:00 2001 From: sanikoyes Date: Thu, 21 Aug 2014 15:51:18 +0800 Subject: Fix reset --- scene/animation/tween.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 48a2fd564b..4acf509283 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -464,7 +464,8 @@ bool Tween::reset(Variant p_object, String p_key) { data.elapsed = 0; data.finish = false; - _apply_tween_value(data, data.initial_val); + if(data.delay == 0) + _apply_tween_value(data, data.initial_val); } } return true; @@ -477,7 +478,8 @@ bool Tween::reset_all() { InterpolateData& data = E->get(); data.elapsed = 0; data.finish = false; - _apply_tween_value(data, data.initial_val); + if(data.delay == 0) + _apply_tween_value(data, data.initial_val); } return true; } -- cgit v1.2.3 From 344420f67cc0e5439bae82e580063f4110def91a Mon Sep 17 00:00:00 2001 From: sanikoyes Date: Fri, 22 Aug 2014 11:24:53 +0800 Subject: Replace object to NodePath Add time callback support Update demo --- demos/misc/tween/engine.cfg | 1 + demos/misc/tween/main.gd | 8 +- demos/misc/tween/main.xml | 14 ++-- scene/animation/tween.cpp | 194 ++++++++++++++++++++++++++++++++------------ scene/animation/tween.h | 29 +++++-- 5 files changed, 177 insertions(+), 69 deletions(-) diff --git a/demos/misc/tween/engine.cfg b/demos/misc/tween/engine.cfg index 7966a56830..f97e540dbd 100644 --- a/demos/misc/tween/engine.cfg +++ b/demos/misc/tween/engine.cfg @@ -3,6 +3,7 @@ name="Tween Demo" main_scene="res://main.xml" icon="icon.png" +target_fps=60 [display] diff --git a/demos/misc/tween/main.gd b/demos/misc/tween/main.gd index 002e720e79..defba21b79 100644 --- a/demos/misc/tween/main.gd +++ b/demos/misc/tween/main.gd @@ -7,7 +7,7 @@ extends Control var trans = ["linear", "sine", "quint", "quart", "quad", "expo", "elastic", "cubic", "circ", "bounce", "back"] var eases = ["in", "out", "in_out", "out_in"] -var modes = ["move", "color", "scale", "rotate", "repeat", "pause"] +var modes = ["move", "color", "scale", "rotate", "callback", "repeat", "pause"] var state = { trans = Tween.TRANS_LINEAR, @@ -105,6 +105,10 @@ func reset_tween(): tween.interpolate_method(sprite, "set_rot", 0, 6.28, 2, state.trans, state.eases) tween.interpolate_method(sprite, "set_rot", 6.28, 0, 2, state.trans, state.eases, 2) + if get_node("modes/callback").is_pressed(): + tween.interpolate_callback(self, "on_callback", 0.5, "0.5 second's after") + tween.interpolate_callback(self, "on_callback", 1.2, "1.2 second's after") + tween.set_repeat(get_node("modes/repeat").is_pressed()) tween.start() @@ -134,3 +138,5 @@ func _on_timeline_value_changed( value ): var runtime = tween.get_runtime() tween.seek(runtime * value / 100) +func on_callback(arg): + print("on_callback -> ", arg) diff --git a/demos/misc/tween/main.xml b/demos/misc/tween/main.xml index f403937818..06c379e214 100644 --- a/demos/misc/tween/main.xml +++ b/demos/misc/tween/main.xml @@ -5,7 +5,7 @@ "names" - + "main" "Control" "_import_path" @@ -63,6 +63,7 @@ "color" "scale" "rotate" + "callback" "repeat" "pause" "label_1" @@ -118,9 +119,9 @@ "conn_count" 2 "node_count" - 34 + 35 "variants" - + "" True 1 @@ -290,11 +291,12 @@ "out_in" 305 402 - 65 + 77 "move" "color" "scale" "rotate" + "callback" "repeat" "pause" 384 @@ -324,9 +326,9 @@ 100 "nodes" - -1, -1, 1, 0, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 20, 9, 21, 10, 0, 0, 0, 23, 22, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 11, 25, 12, 7, 13, 8, 14, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 1, 0, 27, 26, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 15, 8, 16, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 17, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 37, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 20, 7, 15, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 21, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 38, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 22, 7, 15, 8, 23, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 24, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 39, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 25, 7, 15, 8, 26, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 27, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 40, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 28, 7, 15, 8, 29, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 30, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 41, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 31, 7, 15, 8, 32, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 33, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 42, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 34, 7, 15, 8, 35, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 36, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 43, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 37, 7, 15, 8, 38, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 39, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 44, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 40, 7, 15, 8, 41, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 42, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 45, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 43, 7, 15, 8, 44, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 45, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 46, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 46, 7, 15, 8, 47, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 48, 33, 18, 34, 3, 35, 3, 36, 19, 0, 0, 0, 23, 47, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 49, 25, 12, 7, 50, 8, 51, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 13, 0, 27, 48, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 52, 8, 16, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 53, 33, 18, 34, 3, 35, 3, 36, 19, 0, 13, 0, 27, 49, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 20, 7, 52, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 54, 33, 18, 34, 3, 35, 3, 36, 19, 0, 13, 0, 27, 50, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 22, 7, 52, 8, 23, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 55, 33, 18, 34, 3, 35, 3, 36, 19, 0, 13, 0, 27, 51, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 25, 7, 52, 8, 26, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 56, 33, 18, 34, 3, 35, 3, 36, 19, 0, 0, 0, 23, 52, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 40, 25, 12, 7, 57, 8, 58, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 18, 0, 27, 53, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 59, 8, 16, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 60, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 54, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 20, 7, 59, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 61, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 55, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 22, 7, 59, 8, 23, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 62, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 56, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 25, 7, 59, 8, 26, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 63, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 57, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 28, 7, 59, 8, 29, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 64, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 58, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 31, 7, 59, 8, 32, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 65, 33, 18, 34, 3, 35, 3, 36, 19, 0, 0, 0, 23, 54, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 66, 25, 40, 7, 67, 8, 68, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 25, 0, 60, 59, -1, 30, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 69, 8, 70, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 1, 16, 1, 17, 8, 19, 2, 61, 6, 62, 2, 63, 2, 64, 2, 65, 6, 66, 3, 67, 3, 32, 71, 36, 72, 68, 72, 69, 3, 70, 3, 71, 73, 0, 25, 0, 73, 72, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 74, 7, 69, 8, 75, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 25, 0, 60, 74, -1, 31, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 76, 7, 69, 8, 77, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 1, 16, 1, 17, 8, 19, 2, 61, 6, 62, 2, 63, 2, 64, 2, 65, 6, 66, 3, 67, 3, 32, 78, 36, 72, 68, 72, 69, 3, 70, 3, 71, 73, 0, 25, 0, 73, 75, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 79, 7, 69, 8, 80, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 0, 0, 77, 76, -1, 5, 2, 0, 78, 19, 79, 1, 80, 1, 81, 2, 0, 30, 0, 83, 82, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 81, 25, 81, 7, 82, 8, 83, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 0, 31, 0, 85, 84, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 86, 84, 9, 6, 10, 7, 87, 85, 88, 1, 89, 84, 90, 3, 91, 3, 92, 19, 93, 19, 94, 72, 95, 86, 96, 3, 97, 87, 0, 0, 0, 99, 98, -1, 28, 2, 0, 3, 3, 4, 2, 5, 2, 6, 3, 24, 88, 25, 89, 7, 67, 8, 40, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 19, 2, 61, 6, 62, 90, 63, 2, 64, 6, 65, 2, 66, 3, 67, 3, 100, 72, 101, 3, 0 + -1, -1, 1, 0, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 20, 9, 21, 10, 0, 0, 0, 23, 22, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 11, 25, 12, 7, 13, 8, 14, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 1, 0, 27, 26, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 15, 8, 16, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 17, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 37, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 20, 7, 15, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 21, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 38, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 22, 7, 15, 8, 23, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 24, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 39, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 25, 7, 15, 8, 26, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 27, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 40, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 28, 7, 15, 8, 29, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 30, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 41, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 31, 7, 15, 8, 32, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 33, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 42, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 34, 7, 15, 8, 35, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 36, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 43, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 37, 7, 15, 8, 38, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 39, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 44, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 40, 7, 15, 8, 41, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 42, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 45, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 43, 7, 15, 8, 44, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 45, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 46, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 46, 7, 15, 8, 47, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 48, 33, 18, 34, 3, 35, 3, 36, 19, 0, 0, 0, 23, 47, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 49, 25, 12, 7, 50, 8, 51, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 13, 0, 27, 48, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 52, 8, 16, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 53, 33, 18, 34, 3, 35, 3, 36, 19, 0, 13, 0, 27, 49, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 20, 7, 52, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 54, 33, 18, 34, 3, 35, 3, 36, 19, 0, 13, 0, 27, 50, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 22, 7, 52, 8, 23, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 55, 33, 18, 34, 3, 35, 3, 36, 19, 0, 13, 0, 27, 51, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 25, 7, 52, 8, 26, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 56, 33, 18, 34, 3, 35, 3, 36, 19, 0, 0, 0, 23, 52, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 40, 25, 12, 7, 57, 8, 58, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 18, 0, 27, 53, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 59, 8, 16, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 60, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 54, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 20, 7, 59, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 61, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 55, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 22, 7, 59, 8, 23, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 62, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 56, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 25, 7, 59, 8, 26, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 63, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 57, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 28, 7, 59, 8, 29, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 64, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 58, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 31, 7, 59, 8, 32, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 65, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 59, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 34, 7, 59, 8, 35, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 66, 33, 18, 34, 3, 35, 3, 36, 19, 0, 0, 0, 23, 54, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 67, 25, 40, 7, 68, 8, 69, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 26, 0, 61, 60, -1, 30, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 70, 8, 71, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 1, 16, 1, 17, 8, 19, 2, 62, 6, 63, 2, 64, 2, 65, 2, 66, 6, 67, 3, 68, 3, 32, 72, 36, 73, 69, 73, 70, 3, 71, 3, 72, 74, 0, 26, 0, 74, 73, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 75, 7, 70, 8, 76, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 26, 0, 61, 75, -1, 31, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 77, 7, 70, 8, 78, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 1, 16, 1, 17, 8, 19, 2, 62, 6, 63, 2, 64, 2, 65, 2, 66, 6, 67, 3, 68, 3, 32, 79, 36, 73, 69, 73, 70, 3, 71, 3, 72, 74, 0, 26, 0, 74, 76, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 80, 7, 70, 8, 81, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 0, 0, 78, 77, -1, 5, 2, 0, 79, 19, 80, 1, 81, 1, 82, 2, 0, 31, 0, 84, 83, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 82, 25, 82, 7, 83, 8, 84, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 0, 32, 0, 86, 85, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 87, 85, 9, 6, 10, 7, 88, 86, 89, 1, 90, 85, 91, 3, 92, 3, 93, 19, 94, 19, 95, 73, 96, 87, 97, 3, 98, 88, 0, 0, 0, 100, 99, -1, 28, 2, 0, 3, 3, 4, 2, 5, 2, 6, 3, 24, 89, 25, 90, 7, 68, 8, 40, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 19, 2, 62, 6, 63, 91, 64, 2, 65, 6, 66, 2, 67, 3, 68, 3, 101, 73, 102, 3, 0 "conns" - 30, 0, 103, 102, 2, 0, 33, 0, 105, 104, 2, 0 + 31, 0, 104, 103, 2, 0, 34, 0, 106, 105, 2, 0 diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 4acf509283..799b1d19c9 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -123,23 +123,24 @@ 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","node","key"),&Tween::reset ); ObjectTypeDB::bind_method(_MD("reset_all"),&Tween::reset_all ); - ObjectTypeDB::bind_method(_MD("stop","object","key"),&Tween::stop ); + ObjectTypeDB::bind_method(_MD("stop","node","key"),&Tween::stop ); ObjectTypeDB::bind_method(_MD("stop_all"),&Tween::stop_all ); - ObjectTypeDB::bind_method(_MD("resume","object","key"),&Tween::resume ); + ObjectTypeDB::bind_method(_MD("resume","node","key"),&Tween::resume ); ObjectTypeDB::bind_method(_MD("resume_all"),&Tween::resume_all ); - ObjectTypeDB::bind_method(_MD("remove","object","key"),&Tween::remove ); + ObjectTypeDB::bind_method(_MD("remove","node","key"),&Tween::remove ); ObjectTypeDB::bind_method(_MD("remove_all"),&Tween::remove_all ); ObjectTypeDB::bind_method(_MD("seek"),&Tween::seek ); ObjectTypeDB::bind_method(_MD("get_runtime"),&Tween::get_runtime ); - ObjectTypeDB::bind_method(_MD("interpolate_property","object","property","initial_val","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::interpolate_property, DEFVAL(0) ); - ObjectTypeDB::bind_method(_MD("interpolate_method","object","method","initial_val","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::interpolate_method, DEFVAL(0) ); + ObjectTypeDB::bind_method(_MD("interpolate_property","node","property","initial_val","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::interpolate_property, DEFVAL(0) ); + ObjectTypeDB::bind_method(_MD("interpolate_method","node","method","initial_val","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::interpolate_method, DEFVAL(0) ); + ObjectTypeDB::bind_method(_MD("interpolate_callback","node","callback","times_in_sec","args"),&Tween::interpolate_callback, DEFVAL(Variant()) ); - ADD_SIGNAL( MethodInfo("tween_start", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key")) ); - ADD_SIGNAL( MethodInfo("tween_step", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key"), PropertyInfo( Variant::REAL,"elapsed"), PropertyInfo( Variant::OBJECT,"value")) ); - ADD_SIGNAL( MethodInfo("tween_complete", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key")) ); + ADD_SIGNAL( MethodInfo("tween_start", PropertyInfo( Variant::OBJECT,"node"), PropertyInfo( Variant::STRING,"key")) ); + ADD_SIGNAL( MethodInfo("tween_step", PropertyInfo( Variant::OBJECT,"node"), PropertyInfo( Variant::STRING,"key"), PropertyInfo( Variant::REAL,"elapsed"), PropertyInfo( Variant::OBJECT,"value")) ); + ADD_SIGNAL( MethodInfo("tween_complete", PropertyInfo( Variant::OBJECT,"node"), PropertyInfo( Variant::STRING,"key")) ); ADD_PROPERTY( PropertyInfo( Variant::INT, "playback/process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_tween_process_mode"), _SCS("get_tween_process_mode")); //ADD_PROPERTY( PropertyInfo( Variant::BOOL, "activate"), _SCS("set_active"), _SCS("is_active")); @@ -318,25 +319,32 @@ Variant Tween::_run_equation(InterpolateData& p_data) { bool Tween::_apply_tween_value(InterpolateData& p_data, Variant& value) { - Variant& object = p_data.object; + Object *object = get_node(p_data.path); + ERR_FAIL_COND_V(object == NULL, false); - if(p_data.is_method) { + switch(p_data.type) { - Variant *arg[1] = { &value }; - - Variant::CallError error; - object.call(p_data.key, (const Variant **) arg, 1, error); - if(error.error == Variant::CallError::CALL_OK) - return true; + case INTER_PROPERTY: + { + bool valid = false; + object->set(p_data.key,value, &valid); + return valid; + } - return false; + case INTER_METHOD: + { + Variant *arg[1] = { &value }; - } else { + Variant::CallError error; + object->call(p_data.key, (const Variant **) arg, 1, error); + if(error.error == Variant::CallError::CALL_OK) + return true; + return false; + } - bool valid = false; - object.set(p_data.key,value, &valid); - return valid; - } + case INTER_CALLBACK: + break; + }; return true; } @@ -346,25 +354,40 @@ void Tween::_tween_process(float p_delta) { return; p_delta *= speed_scale; + // if repeat and all interpolates was finished then reset all interpolates + if(repeat) { + bool all_finished = true; + + for(List::Element *E=interpolates.front();E;E=E->next()) { + + InterpolateData& data = E->get(); + + if(!data.finish) { + all_finished = false; + break; + } + } + + if(all_finished) + reset_all(); + } + for(List::Element *E=interpolates.front();E;E=E->next()) { InterpolateData& data = E->get(); - if(!data.active) + if(!data.active || data.finish) continue; - if(data.finish) { - if(!repeat) - continue; - data.elapsed = 0; - data.finish = false; - } + Object *object = get_node(data.path); + if(object == NULL) + continue; bool prev_delaying = data.elapsed <= data.delay; data.elapsed += p_delta; if(data.elapsed < data.delay) continue; else if(prev_delaying) - emit_signal("tween_start",data.object,data.key); + emit_signal("tween_start",object,data.key); if(data.elapsed > (data.delay + data.times_in_sec)) { @@ -372,13 +395,29 @@ void Tween::_tween_process(float p_delta) { data.finish = true; } + switch(data.type) + { + case INTER_PROPERTY: + case INTER_METHOD: + break; + case INTER_CALLBACK: + if(data.finish) { + + Variant *arg[1] = { &data.args }; + + Variant::CallError error; + object->call(data.key, (const Variant **) arg, 1, error); + } + continue; + } + Variant result = _run_equation(data); - emit_signal("tween_step",data.object,data.key,data.elapsed,result); + emit_signal("tween_step",object,data.key,data.elapsed,result); _apply_tween_value(data, result); if(data.finish) - emit_signal("tween_complete",data.object,data.key); + emit_signal("tween_complete",object,data.key); } } @@ -455,12 +494,16 @@ bool Tween::start() { return true; } -bool Tween::reset(Variant p_object, String p_key) { +bool Tween::reset(Node *p_node, 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) { + Node *node = get_node(data.path); + if(node == NULL) + continue; + + if(node == p_node && data.key == p_key) { data.elapsed = 0; data.finish = false; @@ -484,12 +527,15 @@ bool Tween::reset_all() { return true; } -bool Tween::stop(Variant p_object, String p_key) { +bool Tween::stop(Node *p_node, 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) + Node *node = get_node(data.path); + if(node == NULL) + continue; + if(node == p_node && data.key == p_key) data.active = false; } return true; @@ -508,7 +554,7 @@ bool Tween::stop_all() { return true; } -bool Tween::resume(Variant p_object, String p_key) { +bool Tween::resume(Node *p_node, String p_key) { set_active(true); _set_process(true); @@ -516,7 +562,10 @@ bool Tween::resume(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) + Node *node = get_node(data.path); + if(node == NULL) + continue; + if(node == p_node && data.key == p_key) data.active = true; } return true; @@ -535,13 +584,15 @@ bool Tween::resume_all() { return true; } -bool Tween::remove(Variant p_object, String p_key) { +bool Tween::remove(Node *p_node, 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) { - + Node *node = get_node(data.path); + if(node == NULL) + continue; + if(node == p_node && data.key == p_key) { interpolates.erase(E); return true; } @@ -569,6 +620,15 @@ bool Tween::seek(real_t p_time) { else if(data.elapsed > (data.delay + data.times_in_sec)) data.elapsed = (data.delay + data.times_in_sec); + switch(data.type) + { + case INTER_PROPERTY: + case INTER_METHOD: + break; + case INTER_CALLBACK: + continue; + } + Variant result = _run_equation(data); _apply_tween_value(data, result); @@ -690,7 +750,7 @@ bool Tween::_calc_delta_val(InterpolateData& p_data) { return true; } -bool Tween::interpolate_property(Variant p_object +bool Tween::interpolate_property(Node *p_node , String p_property , Variant p_initial_val , Variant p_final_val @@ -703,7 +763,7 @@ bool Tween::interpolate_property(Variant p_object if(p_initial_val.get_type() == Variant::INT) p_initial_val = p_initial_val.operator real_t(); if(p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t(); - ERR_FAIL_COND_V(p_object.get_type() != Variant::OBJECT, false); + ERR_FAIL_COND_V(p_node == NULL, false); ERR_FAIL_COND_V(p_initial_val.get_type() != p_final_val.get_type(), false); ERR_FAIL_COND_V(p_times_in_sec <= 0, false); ERR_FAIL_COND_V(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, false); @@ -711,9 +771,8 @@ bool Tween::interpolate_property(Variant p_object ERR_FAIL_COND_V(p_delay < 0, false); bool prop_found = false; - Object *obj = (Object *) p_object; List props; - obj->get_property_list(&props); + p_node->get_property_list(&props); for(List::Element *E=props.front();E;E=E->next()) { PropertyInfo& prop=E->get(); @@ -727,11 +786,11 @@ bool Tween::interpolate_property(Variant p_object InterpolateData data; data.active = true; - data.is_method = false; + data.type = INTER_PROPERTY; data.finish = false; data.elapsed = 0; - data.object = p_object; + data.path = p_node->get_path(); data.key = p_property; data.initial_val = p_initial_val; data.final_val = p_final_val; @@ -747,7 +806,7 @@ bool Tween::interpolate_property(Variant p_object return true; } -bool Tween::interpolate_method(Variant p_object +bool Tween::interpolate_method(Node *p_node , String p_method , Variant p_initial_val , Variant p_final_val @@ -760,23 +819,22 @@ bool Tween::interpolate_method(Variant p_object if(p_initial_val.get_type() == Variant::INT) p_initial_val = p_initial_val.operator real_t(); if(p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t(); - ERR_FAIL_COND_V(p_object.get_type() != Variant::OBJECT, false); + ERR_FAIL_COND_V(p_node == NULL, false); ERR_FAIL_COND_V(p_initial_val.get_type() != p_final_val.get_type(), false); ERR_FAIL_COND_V(p_times_in_sec <= 0, false); ERR_FAIL_COND_V(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, false); ERR_FAIL_COND_V(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false); ERR_FAIL_COND_V(p_delay < 0, false); - Object *obj = (Object *) p_object; - ERR_FAIL_COND_V(!obj->has_method(p_method), false); + ERR_FAIL_COND_V(!p_node->has_method(p_method), false); InterpolateData data; data.active = true; - data.is_method = true; + data.type = INTER_METHOD; data.finish = false; data.elapsed = 0; - data.object = p_object; + data.path = p_node->get_path(); data.key = p_method; data.initial_val = p_initial_val; data.final_val = p_final_val; @@ -792,6 +850,34 @@ bool Tween::interpolate_method(Variant p_object return true; } +bool Tween::interpolate_callback(Node *p_node + , String p_callback + , real_t p_times_in_sec + , Variant p_args +) { + + ERR_FAIL_COND_V(p_node == NULL, false); + ERR_FAIL_COND_V(p_times_in_sec < 0, false); + + ERR_FAIL_COND_V(!p_node->has_method(p_callback), false); + + InterpolateData data; + data.active = true; + data.type = INTER_CALLBACK; + data.finish = false; + data.elapsed = 0; + + data.path = p_node->get_path(); + data.key = p_callback; + data.times_in_sec = p_times_in_sec; + data.delay = 0; + data.args = p_args; + + interpolates.push_back(data); + return true; +} + + Tween::Tween() { //String autoplay; diff --git a/scene/animation/tween.h b/scene/animation/tween.h index 78df7d9c93..8718528ad6 100644 --- a/scene/animation/tween.h +++ b/scene/animation/tween.h @@ -68,14 +68,20 @@ public: }; private: + enum InterpolateType { + + INTER_PROPERTY, + INTER_METHOD, + INTER_CALLBACK, + }; struct InterpolateData { bool active; - bool is_method; + InterpolateType type; bool finish; real_t elapsed; - Variant object; + NodePath path; String key; Variant initial_val; Variant delta_val; @@ -84,6 +90,7 @@ private: TransitionType trans_type; EaseType ease_type; real_t delay; + Variant args; }; String autoplay; @@ -130,19 +137,19 @@ public: float get_speed() const; bool start(); - bool reset(Variant p_object, String p_key); + bool reset(Node *p_node, String p_key); bool reset_all(); - bool stop(Variant p_object, String p_key); + bool stop(Node *p_node, String p_key); bool stop_all(); - bool resume(Variant p_object, String p_key); + bool resume(Node *p_node, String p_key); bool resume_all(); - bool remove(Variant p_object, String p_key); + bool remove(Node *p_node, String p_key); bool remove_all(); bool seek(real_t p_time); real_t get_runtime(); - bool interpolate_property(Variant p_object + bool interpolate_property(Node *p_node , String p_property , Variant p_initial_val , Variant p_final_val @@ -152,7 +159,7 @@ public: , real_t p_delay = 0 ); - bool interpolate_method(Variant p_object + bool interpolate_method(Node *p_node , String p_method , Variant p_initial_val , Variant p_final_val @@ -162,6 +169,12 @@ public: , real_t p_delay = 0 ); + bool interpolate_callback(Node *p_node + , String p_callback + , real_t p_times_in_sec + , Variant p_args = Variant() + ); + Tween(); ~Tween(); }; -- cgit v1.2.3 From 3a93143e5296e1978b283e86205a61745c48fb0f Mon Sep 17 00:00:00 2001 From: sanikoyes Date: Fri, 22 Aug 2014 14:25:41 +0800 Subject: Fix tween seek, add tell function --- scene/animation/tween.cpp | 32 ++++++++++++++++++++++++++------ scene/animation/tween.h | 3 ++- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 799b1d19c9..abb287bc66 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -131,7 +131,8 @@ void Tween::_bind_methods() { ObjectTypeDB::bind_method(_MD("resume_all"),&Tween::resume_all ); ObjectTypeDB::bind_method(_MD("remove","node","key"),&Tween::remove ); ObjectTypeDB::bind_method(_MD("remove_all"),&Tween::remove_all ); - ObjectTypeDB::bind_method(_MD("seek"),&Tween::seek ); + ObjectTypeDB::bind_method(_MD("seek","time"),&Tween::seek ); + ObjectTypeDB::bind_method(_MD("tell"),&Tween::tell ); ObjectTypeDB::bind_method(_MD("get_runtime"),&Tween::get_runtime ); ObjectTypeDB::bind_method(_MD("interpolate_property","node","property","initial_val","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::interpolate_property, DEFVAL(0) ); @@ -615,10 +616,17 @@ bool Tween::seek(real_t p_time) { InterpolateData& data = E->get(); data.elapsed = p_time; - if(data.elapsed < data.delay) + if(data.elapsed < data.delay) { + + data.finish = false; continue; - else if(data.elapsed > (data.delay + data.times_in_sec)) + } + else if(data.elapsed >= (data.delay + data.times_in_sec)) { + + data.finish = true; data.elapsed = (data.delay + data.times_in_sec); + } else + data.finish = false; switch(data.type) { @@ -636,12 +644,24 @@ bool Tween::seek(real_t p_time) { return true; } -real_t Tween::get_runtime() { +real_t Tween::tell() const { + + real_t pos = 0; + for(const List::Element *E=interpolates.front();E;E=E->next()) { + + const InterpolateData& data = E->get(); + if(data.elapsed > pos) + pos = data.elapsed; + } + return pos; +} + +real_t Tween::get_runtime() const { real_t runtime = 0; - for(List::Element *E=interpolates.front();E;E=E->next()) { + for(const List::Element *E=interpolates.front();E;E=E->next()) { - InterpolateData& data = E->get(); + const InterpolateData& data = E->get(); real_t t = data.delay + data.times_in_sec; if(t > runtime) runtime = t; diff --git a/scene/animation/tween.h b/scene/animation/tween.h index 8718528ad6..5d1d9ba5fc 100644 --- a/scene/animation/tween.h +++ b/scene/animation/tween.h @@ -147,7 +147,8 @@ public: bool remove_all(); bool seek(real_t p_time); - real_t get_runtime(); + real_t tell() const; + real_t get_runtime() const; bool interpolate_property(Node *p_node , String p_property -- cgit v1.2.3 From 64413191a96aed4479415a3d235117d9be2519da Mon Sep 17 00:00:00 2001 From: sanikoyes Date: Mon, 25 Aug 2014 13:36:56 +0800 Subject: =?UTF-8?q?tween:=201=E3=80=81add=20follow/targeting=20support=202?= =?UTF-8?q?=E3=80=81update=20demo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demos/misc/tween/main.gd | 29 +++- demos/misc/tween/main.xml | 23 +-- scene/animation/tween.cpp | 366 ++++++++++++++++++++++++++++++++++++++++++---- scene/animation/tween.h | 61 +++++++- 4 files changed, 430 insertions(+), 49 deletions(-) diff --git a/demos/misc/tween/main.gd b/demos/misc/tween/main.gd index defba21b79..d4c33331b8 100644 --- a/demos/misc/tween/main.gd +++ b/demos/misc/tween/main.gd @@ -7,7 +7,7 @@ extends Control var trans = ["linear", "sine", "quint", "quart", "quad", "expo", "elastic", "cubic", "circ", "bounce", "back"] var eases = ["in", "out", "in_out", "out_in"] -var modes = ["move", "color", "scale", "rotate", "callback", "repeat", "pause"] +var modes = ["move", "color", "scale", "rotate", "callback", "follow", "repeat", "pause"] var state = { trans = Tween.TRANS_LINEAR, @@ -82,35 +82,54 @@ func on_color_changed(color): func reset_tween(): var tween = get_node("tween") + var pos = tween.tell() tween.reset_all() tween.remove_all() var sprite = get_node("tween/area/sprite") + var follow = get_node("tween/area/follow") + var follow_2 = get_node("tween/area/follow_2") if get_node("modes/move").is_pressed(): tween.interpolate_method(sprite, "set_pos", Vector2(0,0), Vector2(736, 184), 2, state.trans, state.eases) - tween.interpolate_method(sprite, "set_pos", Vector2(736,184), Vector2(0, 0), 2, state.trans, state.eases, 2) + tween.interpolate_property(sprite, "transform/pos", Vector2(736,184), Vector2(0, 0), 2, state.trans, state.eases, 2) if get_node("modes/color").is_pressed(): tween.interpolate_method(sprite, "set_modulate", get_node("color/color_from").get_color(), get_node("color/color_to").get_color(), 2, state.trans, state.eases) - tween.interpolate_method(sprite, "set_modulate", get_node("color/color_to").get_color(), get_node("color/color_from").get_color(), 2, state.trans, state.eases, 2) + tween.interpolate_property(sprite, "modulate", get_node("color/color_to").get_color(), get_node("color/color_from").get_color(), 2, state.trans, state.eases, 2) else: sprite.set_modulate(Color(1, 1, 1, 1)) if get_node("modes/scale").is_pressed(): tween.interpolate_method(sprite, "set_scale", Vector2(0.5,0.5), Vector2(1.5, 1.5), 2, state.trans, state.eases) - tween.interpolate_method(sprite, "set_scale", Vector2(1.5,1.5), Vector2(0.5, 0.5), 2, state.trans, state.eases, 2) + tween.interpolate_property(sprite, "transform/scale", Vector2(1.5,1.5), Vector2(0.5, 0.5), 2, state.trans, state.eases, 2) + else: + sprite.set_scale(Vector2(1, 1)) if get_node("modes/rotate").is_pressed(): tween.interpolate_method(sprite, "set_rot", 0, 6.28, 2, state.trans, state.eases) - tween.interpolate_method(sprite, "set_rot", 6.28, 0, 2, state.trans, state.eases, 2) + tween.interpolate_property(sprite, "transform/rot", 6.28, 0, 2, state.trans, state.eases, 2) if get_node("modes/callback").is_pressed(): tween.interpolate_callback(self, "on_callback", 0.5, "0.5 second's after") tween.interpolate_callback(self, "on_callback", 1.2, "1.2 second's after") + if get_node("modes/follow").is_pressed(): + follow.show() + follow_2.show() + + tween.follow_method(follow, "set_pos", Vector2(0, 184), sprite, "get_pos", 2, state.trans, state.eases) + tween.targeting_method(follow, "set_pos", sprite, "get_pos", Vector2(0, 184), 2, state.trans, state.eases, 2) + + tween.targeting_property(follow_2, "transform/pos", sprite, "transform/pos", Vector2(736, 0), 2, state.trans, state.eases) + tween.follow_property(follow_2, "transform/pos", Vector2(736, 0), sprite, "transform/pos", 2, state.trans, state.eases, 2) + else: + follow.hide() + follow_2.hide() + tween.set_repeat(get_node("modes/repeat").is_pressed()) tween.start() + tween.seek(pos) if get_node("modes/pause").is_pressed(): tween.stop_all() diff --git a/demos/misc/tween/main.xml b/demos/misc/tween/main.xml index 06c379e214..a1269c4c58 100644 --- a/demos/misc/tween/main.xml +++ b/demos/misc/tween/main.xml @@ -5,7 +5,7 @@ "names" - + "main" "Control" "_import_path" @@ -64,6 +64,7 @@ "scale" "rotate" "callback" + "follow" "repeat" "pause" "label_1" @@ -105,6 +106,7 @@ "modulate" "region" "region_rect" + "follow_2" "timeline" "HSlider" "tick_count" @@ -119,9 +121,9 @@ "conn_count" 2 "node_count" - 35 + 38 "variants" - + "" True 1 @@ -149,11 +151,11 @@ "pixel_snap" False "zoom" - 1.227738 + 1 "use_snap" True "ofs" - -319.009, -56.3619 + -335.329, -441.17 "snap" 8 @@ -289,14 +291,15 @@ "out" "in_out" "out_in" - 305 - 402 + 317 + 492 77 "move" "color" "scale" "rotate" "callback" + "follow" "repeat" "pause" 384 @@ -321,14 +324,16 @@ 1, 1, 1, 1 0, 0, 0, 0 + 0, 184 + 736, 0 40 224 100 "nodes" - -1, -1, 1, 0, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 20, 9, 21, 10, 0, 0, 0, 23, 22, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 11, 25, 12, 7, 13, 8, 14, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 1, 0, 27, 26, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 15, 8, 16, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 17, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 37, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 20, 7, 15, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 21, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 38, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 22, 7, 15, 8, 23, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 24, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 39, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 25, 7, 15, 8, 26, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 27, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 40, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 28, 7, 15, 8, 29, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 30, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 41, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 31, 7, 15, 8, 32, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 33, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 42, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 34, 7, 15, 8, 35, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 36, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 43, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 37, 7, 15, 8, 38, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 39, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 44, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 40, 7, 15, 8, 41, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 42, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 45, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 43, 7, 15, 8, 44, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 45, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 46, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 46, 7, 15, 8, 47, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 48, 33, 18, 34, 3, 35, 3, 36, 19, 0, 0, 0, 23, 47, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 49, 25, 12, 7, 50, 8, 51, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 13, 0, 27, 48, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 52, 8, 16, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 53, 33, 18, 34, 3, 35, 3, 36, 19, 0, 13, 0, 27, 49, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 20, 7, 52, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 54, 33, 18, 34, 3, 35, 3, 36, 19, 0, 13, 0, 27, 50, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 22, 7, 52, 8, 23, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 55, 33, 18, 34, 3, 35, 3, 36, 19, 0, 13, 0, 27, 51, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 25, 7, 52, 8, 26, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 56, 33, 18, 34, 3, 35, 3, 36, 19, 0, 0, 0, 23, 52, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 40, 25, 12, 7, 57, 8, 58, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 18, 0, 27, 53, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 59, 8, 16, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 60, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 54, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 20, 7, 59, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 61, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 55, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 22, 7, 59, 8, 23, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 62, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 56, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 25, 7, 59, 8, 26, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 63, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 57, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 28, 7, 59, 8, 29, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 64, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 58, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 31, 7, 59, 8, 32, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 65, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 59, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 34, 7, 59, 8, 35, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 66, 33, 18, 34, 3, 35, 3, 36, 19, 0, 0, 0, 23, 54, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 67, 25, 40, 7, 68, 8, 69, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 26, 0, 61, 60, -1, 30, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 70, 8, 71, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 1, 16, 1, 17, 8, 19, 2, 62, 6, 63, 2, 64, 2, 65, 2, 66, 6, 67, 3, 68, 3, 32, 72, 36, 73, 69, 73, 70, 3, 71, 3, 72, 74, 0, 26, 0, 74, 73, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 75, 7, 70, 8, 76, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 26, 0, 61, 75, -1, 31, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 77, 7, 70, 8, 78, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 1, 16, 1, 17, 8, 19, 2, 62, 6, 63, 2, 64, 2, 65, 2, 66, 6, 67, 3, 68, 3, 32, 79, 36, 73, 69, 73, 70, 3, 71, 3, 72, 74, 0, 26, 0, 74, 76, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 80, 7, 70, 8, 81, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 0, 0, 78, 77, -1, 5, 2, 0, 79, 19, 80, 1, 81, 1, 82, 2, 0, 31, 0, 84, 83, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 82, 25, 82, 7, 83, 8, 84, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 0, 32, 0, 86, 85, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 87, 85, 9, 6, 10, 7, 88, 86, 89, 1, 90, 85, 91, 3, 92, 3, 93, 19, 94, 19, 95, 73, 96, 87, 97, 3, 98, 88, 0, 0, 0, 100, 99, -1, 28, 2, 0, 3, 3, 4, 2, 5, 2, 6, 3, 24, 89, 25, 90, 7, 68, 8, 40, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 19, 2, 62, 6, 63, 91, 64, 2, 65, 6, 66, 2, 67, 3, 68, 3, 101, 73, 102, 3, 0 + -1, -1, 1, 0, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 20, 9, 21, 10, 0, 0, 0, 23, 22, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 11, 25, 12, 7, 13, 8, 14, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 1, 0, 27, 26, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 15, 8, 16, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 17, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 37, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 20, 7, 15, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 21, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 38, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 22, 7, 15, 8, 23, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 24, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 39, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 25, 7, 15, 8, 26, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 27, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 40, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 28, 7, 15, 8, 29, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 30, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 41, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 31, 7, 15, 8, 32, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 33, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 42, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 34, 7, 15, 8, 35, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 36, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 43, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 37, 7, 15, 8, 38, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 39, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 44, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 40, 7, 15, 8, 41, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 42, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 45, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 43, 7, 15, 8, 44, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 45, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 46, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 46, 7, 15, 8, 47, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 48, 33, 18, 34, 3, 35, 3, 36, 19, 0, 0, 0, 23, 47, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 49, 25, 12, 7, 50, 8, 51, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 13, 0, 27, 48, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 52, 8, 16, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 53, 33, 18, 34, 3, 35, 3, 36, 19, 0, 13, 0, 27, 49, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 20, 7, 52, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 54, 33, 18, 34, 3, 35, 3, 36, 19, 0, 13, 0, 27, 50, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 22, 7, 52, 8, 23, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 55, 33, 18, 34, 3, 35, 3, 36, 19, 0, 13, 0, 27, 51, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 25, 7, 52, 8, 26, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 56, 33, 18, 34, 3, 35, 3, 36, 19, 0, 0, 0, 23, 52, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 40, 25, 12, 7, 57, 8, 58, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 18, 0, 27, 53, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 59, 8, 16, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 60, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 54, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 20, 7, 59, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 61, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 55, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 22, 7, 59, 8, 23, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 62, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 56, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 25, 7, 59, 8, 26, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 63, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 57, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 28, 7, 59, 8, 29, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 64, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 58, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 31, 7, 59, 8, 32, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 65, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 59, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 34, 7, 59, 8, 35, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 66, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 60, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 37, 7, 59, 8, 38, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 67, 33, 18, 34, 3, 35, 3, 36, 19, 0, 0, 0, 23, 54, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 68, 25, 40, 7, 69, 8, 70, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 27, 0, 62, 61, -1, 30, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 71, 8, 72, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 1, 16, 1, 17, 8, 19, 2, 63, 6, 64, 2, 65, 2, 66, 2, 67, 6, 68, 3, 69, 3, 32, 73, 36, 74, 70, 74, 71, 3, 72, 3, 73, 75, 0, 27, 0, 75, 74, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 76, 7, 71, 8, 77, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 27, 0, 62, 76, -1, 31, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 78, 7, 71, 8, 79, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 1, 16, 1, 17, 8, 19, 2, 63, 6, 64, 2, 65, 2, 66, 2, 67, 6, 68, 3, 69, 3, 32, 80, 36, 74, 70, 74, 71, 3, 72, 3, 73, 75, 0, 27, 0, 75, 77, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 81, 7, 71, 8, 82, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 0, 0, 79, 78, -1, 5, 2, 0, 80, 19, 81, 1, 82, 1, 83, 2, 0, 32, 0, 85, 84, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 83, 25, 83, 7, 84, 8, 85, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 0, 33, 0, 87, 86, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 88, 86, 9, 6, 10, 7, 89, 87, 90, 1, 91, 86, 92, 3, 93, 3, 94, 19, 95, 19, 96, 74, 97, 88, 98, 3, 99, 89, 0, 33, 0, 87, 58, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 88, 90, 9, 6, 10, 7, 89, 87, 90, 1, 91, 86, 92, 3, 93, 3, 94, 19, 95, 19, 96, 74, 97, 88, 98, 3, 99, 89, 0, 33, 0, 87, 100, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 88, 91, 9, 6, 10, 7, 89, 87, 90, 1, 91, 86, 92, 3, 93, 3, 94, 19, 95, 19, 96, 74, 97, 88, 98, 3, 99, 89, 0, 0, 0, 102, 101, -1, 28, 2, 0, 3, 3, 4, 2, 5, 2, 6, 3, 24, 92, 25, 93, 7, 69, 8, 40, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 19, 2, 63, 6, 64, 94, 65, 2, 66, 6, 67, 2, 68, 3, 69, 3, 103, 74, 104, 3, 0 "conns" - 31, 0, 104, 103, 2, 0, 34, 0, 106, 105, 2, 0 + 32, 0, 106, 105, 2, 0, 37, 0, 108, 107, 2, 0 diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index abb287bc66..f2df6d47c9 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -138,6 +138,10 @@ void Tween::_bind_methods() { ObjectTypeDB::bind_method(_MD("interpolate_property","node","property","initial_val","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::interpolate_property, DEFVAL(0) ); ObjectTypeDB::bind_method(_MD("interpolate_method","node","method","initial_val","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::interpolate_method, DEFVAL(0) ); ObjectTypeDB::bind_method(_MD("interpolate_callback","node","callback","times_in_sec","args"),&Tween::interpolate_callback, DEFVAL(Variant()) ); + ObjectTypeDB::bind_method(_MD("follow_property","node","property","initial_val","target","target_property","times_in_sec","trans_type","ease_type","delay"),&Tween::follow_property, DEFVAL(0) ); + ObjectTypeDB::bind_method(_MD("follow_method","node","method","initial_val","target","target_method","times_in_sec","trans_type","ease_type","delay"),&Tween::follow_method, DEFVAL(0) ); + ObjectTypeDB::bind_method(_MD("targeting_property","node","property","initial","initial_val","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::targeting_property, DEFVAL(0) ); + ObjectTypeDB::bind_method(_MD("targeting_method","node","method","initial","initial_method","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::targeting_method, DEFVAL(0) ); ADD_SIGNAL( MethodInfo("tween_start", PropertyInfo( Variant::OBJECT,"node"), PropertyInfo( Variant::STRING,"key")) ); ADD_SIGNAL( MethodInfo("tween_step", PropertyInfo( Variant::OBJECT,"node"), PropertyInfo( Variant::STRING,"key"), PropertyInfo( Variant::REAL,"elapsed"), PropertyInfo( Variant::OBJECT,"value")) ); @@ -164,10 +168,94 @@ void Tween::_bind_methods() { BIND_CONSTANT(EASE_OUT_IN); } +Variant& Tween::_get_initial_val(InterpolateData& p_data) { + + switch(p_data.type) { + case INTER_PROPERTY: + case INTER_METHOD: + case FOLLOW_PROPERTY: + case FOLLOW_METHOD: + return p_data.initial_val; + + case TARGETING_PROPERTY: + case TARGETING_METHOD: { + + Node *node = get_node(p_data.target); + ERR_FAIL_COND_V(node == NULL,p_data.initial_val); + + static Variant initial_val; + if(p_data.type == TARGETING_PROPERTY) { + + bool valid = false; + initial_val = node->get(p_data.target_key, &valid); + ERR_FAIL_COND_V(!valid,p_data.initial_val); + } else { + + Variant::CallError error; + initial_val = node->call(p_data.target_key, NULL, 0, error); + ERR_FAIL_COND_V(error.error != Variant::CallError::CALL_OK,p_data.initial_val); + } + return initial_val; + } + break; + } + return p_data.delta_val; +} + +Variant& Tween::_get_delta_val(InterpolateData& p_data) { + + switch(p_data.type) { + case INTER_PROPERTY: + case INTER_METHOD: + return p_data.delta_val; + + case FOLLOW_PROPERTY: + case FOLLOW_METHOD: { + + Node *target = get_node(p_data.target); + ERR_FAIL_COND_V(target == NULL,p_data.initial_val); + + Variant final_val; + + if(p_data.type == FOLLOW_PROPERTY) { + + bool valid = false; + final_val = target->get(p_data.target_key, &valid); + ERR_FAIL_COND_V(!valid,p_data.initial_val); + } else { + + Variant::CallError error; + final_val = target->call(p_data.target_key, NULL, 0, error); + ERR_FAIL_COND_V(error.error != Variant::CallError::CALL_OK,p_data.initial_val); + } + + // convert INT to REAL is better for interpolaters + if(final_val.get_type() == Variant::INT) final_val = final_val.operator real_t(); + _calc_delta_val(p_data.initial_val, final_val, p_data.delta_val); + return p_data.delta_val; + } + break; + + case TARGETING_PROPERTY: + case TARGETING_METHOD: { + + Variant initial_val = _get_initial_val(p_data); + // convert INT to REAL is better for interpolaters + if(initial_val.get_type() == Variant::INT) initial_val = initial_val.operator real_t(); + + //_calc_delta_val(p_data.initial_val, p_data.final_val, p_data.delta_val); + _calc_delta_val(initial_val, p_data.final_val, p_data.delta_val); + return p_data.delta_val; + } + break; + } + return p_data.initial_val; +} + Variant Tween::_run_equation(InterpolateData& p_data) { - Variant& initial_val = p_data.initial_val; - Variant& delta_val = p_data.delta_val; + Variant& initial_val = _get_initial_val(p_data); + Variant& delta_val = _get_delta_val(p_data); Variant result; #define APPLY_EQUATION(element)\ @@ -326,6 +414,8 @@ bool Tween::_apply_tween_value(InterpolateData& p_data, Variant& value) { switch(p_data.type) { case INTER_PROPERTY: + case FOLLOW_PROPERTY: + case TARGETING_PROPERTY: { bool valid = false; object->set(p_data.key,value, &valid); @@ -333,11 +423,17 @@ bool Tween::_apply_tween_value(InterpolateData& p_data, Variant& value) { } case INTER_METHOD: + case FOLLOW_METHOD: + case TARGETING_METHOD: { - Variant *arg[1] = { &value }; - Variant::CallError error; - object->call(p_data.key, (const Variant **) arg, 1, error); + if (value.get_type() != Variant::NIL) { + Variant *arg[1] = { &value }; + object->call(p_data.key, (const Variant **) arg, 1, error); + } else { + object->call(p_data.key, NULL, 0, error); + } + if(error.error == Variant::CallError::CALL_OK) return true; return false; @@ -387,8 +483,11 @@ void Tween::_tween_process(float p_delta) { data.elapsed += p_delta; if(data.elapsed < data.delay) continue; - else if(prev_delaying) + else if(prev_delaying) { + emit_signal("tween_start",object,data.key); + _apply_tween_value(data, data.initial_val); + } if(data.elapsed > (data.delay + data.times_in_sec)) { @@ -404,10 +503,13 @@ void Tween::_tween_process(float p_delta) { case INTER_CALLBACK: if(data.finish) { - Variant *arg[1] = { &data.args }; - Variant::CallError error; - object->call(data.key, (const Variant **) arg, 1, error); + if (data.arg.get_type() != Variant::NIL) { + Variant *arg[1] = { &data.arg }; + object->call(data.key, (const Variant **) arg, 1, error); + } else { + object->call(data.key, NULL, 0, error); + } } continue; } @@ -669,11 +771,11 @@ real_t Tween::get_runtime() const { return runtime; } -bool Tween::_calc_delta_val(InterpolateData& p_data) { +bool Tween::_calc_delta_val(const Variant& p_initial_val, const Variant& p_final_val, Variant& p_delta_val) { - Variant& initial_val = p_data.initial_val; - Variant& delta_val = p_data.delta_val; - Variant& final_val = p_data.final_val; + const Variant& initial_val = p_initial_val; + const Variant& final_val = p_final_val; + Variant& delta_val = p_delta_val; switch(initial_val.get_type()) { case Variant::INT: @@ -790,19 +892,9 @@ bool Tween::interpolate_property(Node *p_node ERR_FAIL_COND_V(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false); ERR_FAIL_COND_V(p_delay < 0, false); - bool prop_found = false; - List props; - p_node->get_property_list(&props); - for(List::Element *E=props.front();E;E=E->next()) { - - PropertyInfo& prop=E->get(); - if(prop.name==p_property) - { - prop_found = true; - break; - } - } - ERR_FAIL_COND_V(!prop_found, false); + bool prop_valid = false; + p_node->get(p_property,&prop_valid); + ERR_FAIL_COND_V(!prop_valid, false); InterpolateData data; data.active = true; @@ -819,7 +911,7 @@ bool Tween::interpolate_property(Node *p_node data.ease_type = p_ease_type; data.delay = p_delay; - if(!_calc_delta_val(data)) + if(!_calc_delta_val(data.initial_val, data.final_val, data.delta_val)) return false; interpolates.push_back(data); @@ -863,7 +955,7 @@ bool Tween::interpolate_method(Node *p_node data.ease_type = p_ease_type; data.delay = p_delay; - if(!_calc_delta_val(data)) + if(!_calc_delta_val(data.initial_val, data.final_val, data.delta_val)) return false; interpolates.push_back(data); @@ -873,7 +965,7 @@ bool Tween::interpolate_method(Node *p_node bool Tween::interpolate_callback(Node *p_node , String p_callback , real_t p_times_in_sec - , Variant p_args + , Variant p_arg ) { ERR_FAIL_COND_V(p_node == NULL, false); @@ -891,13 +983,227 @@ bool Tween::interpolate_callback(Node *p_node data.key = p_callback; data.times_in_sec = p_times_in_sec; data.delay = 0; - data.args = p_args; + data.arg = p_arg; + + interpolates.push_back(data); + return true; +} + +bool Tween::follow_property(Node *p_node + , String p_property + , Variant p_initial_val + , Node *p_target + , String p_target_property + , real_t p_times_in_sec + , TransitionType p_trans_type + , EaseType p_ease_type + , real_t p_delay +) { + // convert INT to REAL is better for interpolaters + if(p_initial_val.get_type() == Variant::INT) p_initial_val = p_initial_val.operator real_t(); + + ERR_FAIL_COND_V(p_node == NULL, false); + ERR_FAIL_COND_V(p_target == NULL, false); + ERR_FAIL_COND_V(p_times_in_sec <= 0, false); + ERR_FAIL_COND_V(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, false); + ERR_FAIL_COND_V(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false); + ERR_FAIL_COND_V(p_delay < 0, false); + + bool prop_valid = false; + p_node->get(p_property,&prop_valid); + ERR_FAIL_COND_V(!prop_valid, false); + + bool target_prop_valid = false; + Variant target_val = p_target->get(p_target_property,&target_prop_valid); + ERR_FAIL_COND_V(!target_prop_valid, false); + + // convert INT to REAL is better for interpolaters + if(target_val.get_type() == Variant::INT) target_val = target_val.operator real_t(); + ERR_FAIL_COND_V(target_val.get_type() != p_initial_val.get_type(), false); + + InterpolateData data; + data.active = true; + data.type = FOLLOW_PROPERTY; + data.finish = false; + data.elapsed = 0; + + data.path = p_node->get_path(); + data.key = p_property; + data.initial_val = p_initial_val; + data.target = p_target->get_path(); + data.target_key = p_target_property; + data.times_in_sec = p_times_in_sec; + data.trans_type = p_trans_type; + data.ease_type = p_ease_type; + data.delay = p_delay; + + interpolates.push_back(data); + return true; +} + +bool Tween::follow_method(Node *p_node + , String p_method + , Variant p_initial_val + , Node *p_target + , String p_target_method + , real_t p_times_in_sec + , TransitionType p_trans_type + , EaseType p_ease_type + , real_t p_delay +) { + // convert INT to REAL is better for interpolaters + if(p_initial_val.get_type() == Variant::INT) p_initial_val = p_initial_val.operator real_t(); + + ERR_FAIL_COND_V(p_node == NULL, false); + ERR_FAIL_COND_V(p_target == NULL, false); + ERR_FAIL_COND_V(p_times_in_sec <= 0, false); + ERR_FAIL_COND_V(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, false); + ERR_FAIL_COND_V(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false); + ERR_FAIL_COND_V(p_delay < 0, false); + + ERR_FAIL_COND_V(!p_node->has_method(p_method), false); + ERR_FAIL_COND_V(!p_target->has_method(p_target_method), false); + + Variant::CallError error; + Variant target_val = p_target->call(p_target_method, NULL, 0, error); + ERR_FAIL_COND_V(error.error != Variant::CallError::CALL_OK, false); + + // convert INT to REAL is better for interpolaters + if(target_val.get_type() == Variant::INT) target_val = target_val.operator real_t(); + ERR_FAIL_COND_V(target_val.get_type() != p_initial_val.get_type(), false); + + InterpolateData data; + data.active = true; + data.type = FOLLOW_METHOD; + data.finish = false; + data.elapsed = 0; + + data.path = p_node->get_path(); + data.key = p_method; + data.initial_val = p_initial_val; + data.target = p_target->get_path(); + data.target_key = p_target_method; + data.times_in_sec = p_times_in_sec; + data.trans_type = p_trans_type; + data.ease_type = p_ease_type; + data.delay = p_delay; + + interpolates.push_back(data); + return true; +} + +bool Tween::targeting_property(Node *p_node + , String p_property + , Node *p_initial + , String p_initial_property + , Variant p_final_val + , real_t p_times_in_sec + , TransitionType p_trans_type + , EaseType p_ease_type + , real_t p_delay +) { + // convert INT to REAL is better for interpolaters + if(p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t(); + + ERR_FAIL_COND_V(p_node == NULL, false); + ERR_FAIL_COND_V(p_initial == NULL, false); + ERR_FAIL_COND_V(p_times_in_sec <= 0, false); + ERR_FAIL_COND_V(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, false); + ERR_FAIL_COND_V(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false); + ERR_FAIL_COND_V(p_delay < 0, false); + + bool prop_valid = false; + p_node->get(p_property,&prop_valid); + ERR_FAIL_COND_V(!prop_valid, false); + + bool initial_prop_valid = false; + Variant initial_val = p_initial->get(p_initial_property,&initial_prop_valid); + ERR_FAIL_COND_V(!initial_prop_valid, false); + + // convert INT to REAL is better for interpolaters + if(initial_val.get_type() == Variant::INT) initial_val = initial_val.operator real_t(); + ERR_FAIL_COND_V(initial_val.get_type() != p_final_val.get_type(), false); + + InterpolateData data; + data.active = true; + data.type = TARGETING_PROPERTY; + data.finish = false; + data.elapsed = 0; + + data.path = p_node->get_path(); + data.key = p_property; + data.target = p_initial->get_path(); + data.target_key = p_initial_property; + data.initial_val = initial_val; + data.final_val = p_final_val; + data.times_in_sec = p_times_in_sec; + data.trans_type = p_trans_type; + data.ease_type = p_ease_type; + data.delay = p_delay; + + if(!_calc_delta_val(data.initial_val, data.final_val, data.delta_val)) + return false; interpolates.push_back(data); return true; } +bool Tween::targeting_method(Node *p_node + , String p_method + , Node *p_initial + , String p_initial_method + , Variant p_final_val + , real_t p_times_in_sec + , TransitionType p_trans_type + , EaseType p_ease_type + , real_t p_delay +) { + // convert INT to REAL is better for interpolaters + if(p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t(); + + ERR_FAIL_COND_V(p_node == NULL, false); + ERR_FAIL_COND_V(p_initial == NULL, false); + ERR_FAIL_COND_V(p_times_in_sec <= 0, false); + ERR_FAIL_COND_V(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, false); + ERR_FAIL_COND_V(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false); + ERR_FAIL_COND_V(p_delay < 0, false); + + ERR_FAIL_COND_V(!p_node->has_method(p_method), false); + ERR_FAIL_COND_V(!p_initial->has_method(p_initial_method), false); + + Variant::CallError error; + Variant initial_val = p_initial->call(p_initial_method, NULL, 0, error); + ERR_FAIL_COND_V(error.error != Variant::CallError::CALL_OK, false); + + // convert INT to REAL is better for interpolaters + if(initial_val.get_type() == Variant::INT) initial_val = initial_val.operator real_t(); + ERR_FAIL_COND_V(initial_val.get_type() != p_final_val.get_type(), false); + + InterpolateData data; + data.active = true; + data.type = TARGETING_METHOD; + data.finish = false; + data.elapsed = 0; + + data.path = p_node->get_path(); + data.key = p_method; + data.target = p_initial->get_path(); + data.target_key = p_initial_method; + data.initial_val = initial_val; + data.final_val = p_final_val; + data.times_in_sec = p_times_in_sec; + data.trans_type = p_trans_type; + data.ease_type = p_ease_type; + data.delay = p_delay; + + if(!_calc_delta_val(data.initial_val, data.final_val, data.delta_val)) + return false; + + interpolates.push_back(data); + return true; +} + Tween::Tween() { //String autoplay; diff --git a/scene/animation/tween.h b/scene/animation/tween.h index 5d1d9ba5fc..51d5fc9132 100644 --- a/scene/animation/tween.h +++ b/scene/animation/tween.h @@ -72,6 +72,10 @@ private: INTER_PROPERTY, INTER_METHOD, + FOLLOW_PROPERTY, + FOLLOW_METHOD, + TARGETING_PROPERTY, + TARGETING_METHOD, INTER_CALLBACK, }; @@ -80,17 +84,18 @@ private: InterpolateType type; bool finish; real_t elapsed; - NodePath path; - String key; + StringName key; Variant initial_val; Variant delta_val; Variant final_val; + NodePath target; + StringName target_key; real_t times_in_sec; TransitionType trans_type; EaseType ease_type; real_t delay; - Variant args; + Variant arg; }; String autoplay; @@ -106,8 +111,10 @@ private: static interpolater interpolaters[TRANS_COUNT][EASE_COUNT]; real_t _run_equation(TransitionType p_trans_type, EaseType p_ease_type, real_t t, real_t b, real_t c, real_t d); + Variant& _get_delta_val(InterpolateData& p_data); + Variant& _get_initial_val(InterpolateData& p_data); Variant _run_equation(InterpolateData& p_data); - bool _calc_delta_val(InterpolateData& p_data); + bool _calc_delta_val(const Variant& p_initial_val, const Variant& p_final_val, Variant& p_delta_val); bool _apply_tween_value(InterpolateData& p_data, Variant& value); void _tween_process(float p_delta); @@ -173,7 +180,51 @@ public: bool interpolate_callback(Node *p_node , String p_callback , real_t p_times_in_sec - , Variant p_args = Variant() + , Variant p_arg = Variant() + ); + + bool follow_property(Node *p_node + , String p_property + , Variant p_initial_val + , Node *p_target + , String p_target_property + , real_t p_times_in_sec + , TransitionType p_trans_type + , EaseType p_ease_type + , real_t p_delay = 0 + ); + + bool follow_method(Node *p_node + , String p_method + , Variant p_initial_val + , Node *p_target + , String p_target_method + , real_t p_times_in_sec + , TransitionType p_trans_type + , EaseType p_ease_type + , real_t p_delay = 0 + ); + + bool targeting_property(Node *p_node + , String p_property + , Node *p_initial + , String p_initial_property + , Variant p_final_val + , real_t p_times_in_sec + , TransitionType p_trans_type + , EaseType p_ease_type + , real_t p_delay = 0 + ); + + bool targeting_method(Node *p_node + , String p_method + , Node *p_initial + , String p_initial_method + , Variant p_final_val + , real_t p_times_in_sec + , TransitionType p_trans_type + , EaseType p_ease_type + , real_t p_delay = 0 ); Tween(); -- cgit v1.2.3 From 5bddfa201e4982a27dfa2e6d70e2433e7861889c Mon Sep 17 00:00:00 2001 From: sanikoyes Date: Wed, 27 Aug 2014 15:39:04 +0800 Subject: Update tween demo --- demos/misc/tween/main.gd | 31 +++++++++++++++++-------------- demos/misc/tween/main.xml | 41 ++++++++++++++++++++++++++++++++++------- 2 files changed, 51 insertions(+), 21 deletions(-) diff --git a/demos/misc/tween/main.gd b/demos/misc/tween/main.gd index d4c33331b8..364651c827 100644 --- a/demos/misc/tween/main.gd +++ b/demos/misc/tween/main.gd @@ -70,10 +70,10 @@ func on_modes_changed(name): if name == "pause": if get_node("modes/pause").is_pressed(): tween.stop_all() - get_node("timeline").show() + get_node("timeline").set_ignore_mouse(false) else: tween.resume_all() - get_node("timeline").hide() + get_node("timeline").set_ignore_mouse(true) else: reset_tween() @@ -89,10 +89,11 @@ func reset_tween(): var sprite = get_node("tween/area/sprite") var follow = get_node("tween/area/follow") var follow_2 = get_node("tween/area/follow_2") - + var size = get_node("tween/area").get_size() + if get_node("modes/move").is_pressed(): - tween.interpolate_method(sprite, "set_pos", Vector2(0,0), Vector2(736, 184), 2, state.trans, state.eases) - tween.interpolate_property(sprite, "transform/pos", Vector2(736,184), Vector2(0, 0), 2, state.trans, state.eases, 2) + tween.interpolate_method(sprite, "set_pos", Vector2(0,0), Vector2(size.width, size.height), 2, state.trans, state.eases) + tween.interpolate_property(sprite, "transform/pos", Vector2(size.width,size.height), Vector2(0, 0), 2, state.trans, state.eases, 2) if get_node("modes/color").is_pressed(): tween.interpolate_method(sprite, "set_modulate", get_node("color/color_from").get_color(), get_node("color/color_to").get_color(), 2, state.trans, state.eases) @@ -107,8 +108,8 @@ func reset_tween(): sprite.set_scale(Vector2(1, 1)) if get_node("modes/rotate").is_pressed(): - tween.interpolate_method(sprite, "set_rot", 0, 6.28, 2, state.trans, state.eases) - tween.interpolate_property(sprite, "transform/rot", 6.28, 0, 2, state.trans, state.eases, 2) + tween.interpolate_method(sprite, "_set_rotd", 0, 360, 2, state.trans, state.eases) + tween.interpolate_property(sprite, "transform/rot", 360, 0, 2, state.trans, state.eases, 2) if get_node("modes/callback").is_pressed(): tween.interpolate_callback(self, "on_callback", 0.5, "0.5 second's after") @@ -118,11 +119,11 @@ func reset_tween(): follow.show() follow_2.show() - tween.follow_method(follow, "set_pos", Vector2(0, 184), sprite, "get_pos", 2, state.trans, state.eases) - tween.targeting_method(follow, "set_pos", sprite, "get_pos", Vector2(0, 184), 2, state.trans, state.eases, 2) + tween.follow_method(follow, "set_pos", Vector2(0, size.height), sprite, "get_pos", 2, state.trans, state.eases) + tween.targeting_method(follow, "set_pos", sprite, "get_pos", Vector2(0, size.height), 2, state.trans, state.eases, 2) - tween.targeting_property(follow_2, "transform/pos", sprite, "transform/pos", Vector2(736, 0), 2, state.trans, state.eases) - tween.follow_property(follow_2, "transform/pos", Vector2(736, 0), sprite, "transform/pos", 2, state.trans, state.eases, 2) + tween.targeting_property(follow_2, "transform/pos", sprite, "transform/pos", Vector2(size.width, 0), 2, state.trans, state.eases) + tween.follow_property(follow_2, "transform/pos", Vector2(size.width, 0), sprite, "transform/pos", 2, state.trans, state.eases, 2) else: follow.hide() follow_2.hide() @@ -133,13 +134,14 @@ func reset_tween(): if get_node("modes/pause").is_pressed(): tween.stop_all() - get_node("timeline").show() + get_node("timeline").set_ignore_mouse(false) get_node("timeline").set_value(0) else: tween.resume_all() - get_node("timeline").hide() + get_node("timeline").set_ignore_mouse(true) func _on_tween_step( object, key, elapsed, value ): + var timeline = get_node("timeline") var tween = get_node("tween") @@ -158,4 +160,5 @@ func _on_timeline_value_changed( value ): tween.seek(runtime * value / 100) func on_callback(arg): - print("on_callback -> ", arg) + var label = get_node("tween/area/label") + label.add_text("on_callback -> " + arg + "\n") diff --git a/demos/misc/tween/main.xml b/demos/misc/tween/main.xml index a1269c4c58..6580ba04da 100644 --- a/demos/misc/tween/main.xml +++ b/demos/misc/tween/main.xml @@ -5,7 +5,7 @@ "names" - + "main" "Control" "_import_path" @@ -92,6 +92,12 @@ "playback/speed" "area" "Panel" + "label" + "RichTextLabel" + "scroll_active" + "scroll_follow" + "tab_size" + "selection_enabled" "sprite" "Sprite" "transform/pos" @@ -121,9 +127,9 @@ "conn_count" 2 "node_count" - 38 + 39 "variants" - + "" True 1 @@ -151,11 +157,11 @@ "pixel_snap" False "zoom" - 1 + 1.360374 "use_snap" True "ofs" - -335.329, -441.17 + -215.073, -20.8125 "snap" 8 @@ -250,6 +256,10 @@ 256 129 582 + + "_editor_collapsed" + True + 73 26 "linear" @@ -286,6 +296,10 @@ 152 215 372 + + "_editor_collapsed" + True + 63 "in" "out" @@ -293,6 +307,10 @@ "out_in" 317 492 + + "_editor_collapsed" + True + 77 "move" "color" @@ -305,6 +323,10 @@ 384 760 592 + + "_editor_collapsed" + True + 376 19 "Color From:" @@ -320,6 +342,11 @@ 32 768 216 + 24 + 552 + 160 + "" + 4 0, 0 1, 1, 1, 1 @@ -331,9 +358,9 @@ 100 "nodes" - -1, -1, 1, 0, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 20, 9, 21, 10, 0, 0, 0, 23, 22, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 11, 25, 12, 7, 13, 8, 14, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 1, 0, 27, 26, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 15, 8, 16, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 17, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 37, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 20, 7, 15, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 21, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 38, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 22, 7, 15, 8, 23, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 24, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 39, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 25, 7, 15, 8, 26, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 27, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 40, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 28, 7, 15, 8, 29, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 30, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 41, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 31, 7, 15, 8, 32, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 33, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 42, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 34, 7, 15, 8, 35, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 36, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 43, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 37, 7, 15, 8, 38, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 39, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 44, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 40, 7, 15, 8, 41, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 42, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 45, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 43, 7, 15, 8, 44, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 45, 33, 18, 34, 3, 35, 3, 36, 19, 0, 1, 0, 27, 46, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 46, 7, 15, 8, 47, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 48, 33, 18, 34, 3, 35, 3, 36, 19, 0, 0, 0, 23, 47, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 49, 25, 12, 7, 50, 8, 51, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 13, 0, 27, 48, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 52, 8, 16, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 53, 33, 18, 34, 3, 35, 3, 36, 19, 0, 13, 0, 27, 49, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 20, 7, 52, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 54, 33, 18, 34, 3, 35, 3, 36, 19, 0, 13, 0, 27, 50, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 22, 7, 52, 8, 23, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 55, 33, 18, 34, 3, 35, 3, 36, 19, 0, 13, 0, 27, 51, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 25, 7, 52, 8, 26, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 56, 33, 18, 34, 3, 35, 3, 36, 19, 0, 0, 0, 23, 52, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 40, 25, 12, 7, 57, 8, 58, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 18, 0, 27, 53, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 59, 8, 16, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 60, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 54, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 20, 7, 59, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 61, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 55, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 22, 7, 59, 8, 23, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 62, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 56, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 25, 7, 59, 8, 26, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 63, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 57, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 28, 7, 59, 8, 29, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 64, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 58, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 31, 7, 59, 8, 32, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 65, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 59, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 34, 7, 59, 8, 35, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 66, 33, 18, 34, 3, 35, 3, 36, 19, 0, 18, 0, 27, 60, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 37, 7, 59, 8, 38, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 67, 33, 18, 34, 3, 35, 3, 36, 19, 0, 0, 0, 23, 54, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 68, 25, 40, 7, 69, 8, 70, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 27, 0, 62, 61, -1, 30, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 71, 8, 72, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 1, 16, 1, 17, 8, 19, 2, 63, 6, 64, 2, 65, 2, 66, 2, 67, 6, 68, 3, 69, 3, 32, 73, 36, 74, 70, 74, 71, 3, 72, 3, 73, 75, 0, 27, 0, 75, 74, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 76, 7, 71, 8, 77, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 27, 0, 62, 76, -1, 31, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 78, 7, 71, 8, 79, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 1, 16, 1, 17, 8, 19, 2, 63, 6, 64, 2, 65, 2, 66, 2, 67, 6, 68, 3, 69, 3, 32, 80, 36, 74, 70, 74, 71, 3, 72, 3, 73, 75, 0, 27, 0, 75, 77, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 81, 7, 71, 8, 82, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 0, 0, 79, 78, -1, 5, 2, 0, 80, 19, 81, 1, 82, 1, 83, 2, 0, 32, 0, 85, 84, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 83, 25, 83, 7, 84, 8, 85, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 0, 33, 0, 87, 86, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 88, 86, 9, 6, 10, 7, 89, 87, 90, 1, 91, 86, 92, 3, 93, 3, 94, 19, 95, 19, 96, 74, 97, 88, 98, 3, 99, 89, 0, 33, 0, 87, 58, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 88, 90, 9, 6, 10, 7, 89, 87, 90, 1, 91, 86, 92, 3, 93, 3, 94, 19, 95, 19, 96, 74, 97, 88, 98, 3, 99, 89, 0, 33, 0, 87, 100, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 88, 91, 9, 6, 10, 7, 89, 87, 90, 1, 91, 86, 92, 3, 93, 3, 94, 19, 95, 19, 96, 74, 97, 88, 98, 3, 99, 89, 0, 0, 0, 102, 101, -1, 28, 2, 0, 3, 3, 4, 2, 5, 2, 6, 3, 24, 92, 25, 93, 7, 69, 8, 40, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 19, 2, 63, 6, 64, 94, 65, 2, 66, 6, 67, 2, 68, 3, 69, 3, 103, 74, 104, 3, 0 + -1, -1, 1, 0, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 20, 9, 21, 10, 0, 0, 0, 23, 22, -1, 21, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 11, 25, 12, 7, 13, 8, 14, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 21, 15, 0, 1, 0, 27, 26, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 16, 8, 17, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 18, 33, 19, 34, 3, 35, 3, 36, 20, 0, 1, 0, 27, 37, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 21, 7, 16, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 22, 33, 19, 34, 3, 35, 3, 36, 20, 0, 1, 0, 27, 38, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 23, 7, 16, 8, 24, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 25, 33, 19, 34, 3, 35, 3, 36, 20, 0, 1, 0, 27, 39, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 26, 7, 16, 8, 27, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 28, 33, 19, 34, 3, 35, 3, 36, 20, 0, 1, 0, 27, 40, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 29, 7, 16, 8, 30, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 31, 33, 19, 34, 3, 35, 3, 36, 20, 0, 1, 0, 27, 41, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 32, 7, 16, 8, 33, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 34, 33, 19, 34, 3, 35, 3, 36, 20, 0, 1, 0, 27, 42, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 35, 7, 16, 8, 36, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 37, 33, 19, 34, 3, 35, 3, 36, 20, 0, 1, 0, 27, 43, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 38, 7, 16, 8, 39, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 40, 33, 19, 34, 3, 35, 3, 36, 20, 0, 1, 0, 27, 44, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 41, 7, 16, 8, 42, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 43, 33, 19, 34, 3, 35, 3, 36, 20, 0, 1, 0, 27, 45, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 44, 7, 16, 8, 45, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 46, 33, 19, 34, 3, 35, 3, 36, 20, 0, 1, 0, 27, 46, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 47, 7, 16, 8, 48, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 49, 33, 19, 34, 3, 35, 3, 36, 20, 0, 0, 0, 23, 47, -1, 21, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 50, 25, 12, 7, 51, 8, 52, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 21, 53, 0, 13, 0, 27, 48, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 54, 8, 17, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 55, 33, 19, 34, 3, 35, 3, 36, 20, 0, 13, 0, 27, 49, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 21, 7, 54, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 56, 33, 19, 34, 3, 35, 3, 36, 20, 0, 13, 0, 27, 50, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 23, 7, 54, 8, 24, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 57, 33, 19, 34, 3, 35, 3, 36, 20, 0, 13, 0, 27, 51, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 26, 7, 54, 8, 27, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 58, 33, 19, 34, 3, 35, 3, 36, 20, 0, 0, 0, 23, 52, -1, 21, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 41, 25, 12, 7, 59, 8, 60, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 21, 61, 0, 18, 0, 27, 53, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 62, 8, 17, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 63, 33, 19, 34, 3, 35, 3, 36, 20, 0, 18, 0, 27, 54, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 21, 7, 62, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 64, 33, 19, 34, 3, 35, 3, 36, 20, 0, 18, 0, 27, 55, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 23, 7, 62, 8, 24, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 65, 33, 19, 34, 3, 35, 3, 36, 20, 0, 18, 0, 27, 56, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 26, 7, 62, 8, 27, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 66, 33, 19, 34, 3, 35, 3, 36, 20, 0, 18, 0, 27, 57, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 29, 7, 62, 8, 30, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 67, 33, 19, 34, 3, 35, 3, 36, 20, 0, 18, 0, 27, 58, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 32, 7, 62, 8, 33, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 68, 33, 19, 34, 3, 35, 3, 36, 20, 0, 18, 0, 27, 59, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 35, 7, 62, 8, 36, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 69, 33, 19, 34, 3, 35, 3, 36, 20, 0, 18, 0, 27, 60, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 38, 7, 62, 8, 39, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 70, 33, 19, 34, 3, 35, 3, 36, 20, 0, 0, 0, 23, 54, -1, 21, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 71, 25, 41, 7, 72, 8, 73, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 21, 74, 0, 27, 0, 62, 61, -1, 30, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 75, 8, 76, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 1, 16, 1, 17, 8, 19, 2, 63, 6, 64, 2, 65, 2, 66, 2, 67, 6, 68, 3, 69, 3, 32, 77, 36, 78, 70, 78, 71, 3, 72, 3, 73, 79, 0, 27, 0, 75, 74, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 80, 7, 75, 8, 81, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 27, 0, 62, 76, -1, 31, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 82, 7, 75, 8, 83, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 1, 16, 1, 17, 8, 19, 2, 63, 6, 64, 2, 65, 2, 66, 2, 67, 6, 68, 3, 69, 3, 32, 84, 36, 78, 70, 78, 71, 3, 72, 3, 73, 79, 0, 27, 0, 75, 77, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 85, 7, 75, 8, 86, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 0, 0, 79, 78, -1, 5, 2, 0, 80, 20, 81, 1, 82, 1, 83, 2, 0, 32, 0, 85, 84, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 87, 25, 87, 7, 88, 8, 89, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 0, 33, 0, 87, 86, -1, 24, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 33, 25, 90, 7, 91, 8, 92, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 19, 2, 32, 93, 88, 1, 89, 1, 90, 94, 91, 3, 0, 33, 0, 93, 92, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 94, 95, 9, 6, 10, 7, 95, 96, 96, 1, 97, 95, 98, 3, 99, 3, 100, 20, 101, 20, 102, 78, 103, 97, 104, 3, 105, 98, 0, 33, 0, 93, 58, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 94, 99, 9, 6, 10, 7, 95, 96, 96, 1, 97, 95, 98, 3, 99, 3, 100, 20, 101, 20, 102, 78, 103, 97, 104, 3, 105, 98, 0, 33, 0, 93, 106, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 94, 100, 9, 6, 10, 7, 95, 96, 96, 1, 97, 95, 98, 3, 99, 3, 100, 20, 101, 20, 102, 78, 103, 97, 104, 3, 105, 98, 0, 0, 0, 108, 107, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 101, 25, 102, 7, 72, 8, 41, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 19, 2, 63, 6, 64, 103, 65, 2, 66, 6, 67, 2, 68, 3, 69, 3, 109, 78, 110, 3, 0 "conns" - 32, 0, 106, 105, 2, 0, 37, 0, 108, 107, 2, 0 + 32, 0, 112, 111, 2, 0, 38, 0, 114, 113, 2, 0 -- cgit v1.2.3