diff --git a/demos/misc/tween/engine.cfg b/demos/misc/tween/engine.cfg
new file mode 100644
index 00000000000..7966a568307
--- /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 00000000000..5f6828f6f41
--- /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 00000000000..8c6c9c46394
--- /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 eebb0d67774..305e105fdd7 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 5a8186cc21c..7dd917dc8ee 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