diff --git a/demos/misc/tween/main.gd b/demos/misc/tween/main.gd
index defba21b792..d4c33331b82 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 06c379e214d..a1269c4c585 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 abb287bc66d..f2df6d47c97 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,12 +983,226 @@ 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() {
diff --git a/scene/animation/tween.h b/scene/animation/tween.h
index 5d1d9ba5fce..51d5fc91328 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();