diff options
author | sanikoyes <sanikoyes@163.com> | 2014-08-22 11:24:53 +0800 |
---|---|---|
committer | sanikoyes <sanikoyes@163.com> | 2014-08-22 11:24:53 +0800 |
commit | 344420f67cc0e5439bae82e580063f4110def91a (patch) | |
tree | 394f9e48d2ef8100baaa2e1819cfdf50a8a5ff03 | |
parent | d7eb4550b0d33d3b932c166d2216a4c468d49649 (diff) |
Replace object to NodePath
Add time callback support
Update demo
-rw-r--r-- | demos/misc/tween/engine.cfg | 1 | ||||
-rw-r--r-- | demos/misc/tween/main.gd | 8 | ||||
-rw-r--r-- | demos/misc/tween/main.xml | 14 | ||||
-rw-r--r-- | scene/animation/tween.cpp | 194 | ||||
-rw-r--r-- | 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 @@ <main_resource> <dictionary name="_bundled" shared="false"> <string> "names" </string> - <string_array len="106"> + <string_array len="107"> <string> "main" </string> <string> "Control" </string> <string> "_import_path" </string> @@ -63,6 +63,7 @@ <string> "color" </string> <string> "scale" </string> <string> "rotate" </string> + <string> "callback" </string> <string> "repeat" </string> <string> "pause" </string> <string> "label_1" </string> @@ -118,9 +119,9 @@ <string> "conn_count" </string> <int> 2 </int> <string> "node_count" </string> - <int> 34 </int> + <int> 35 </int> <string> "variants" </string> - <array len="91" shared="false"> + <array len="92" shared="false"> <node_path> "" </node_path> <bool> True </bool> <real> 1 </real> @@ -290,11 +291,12 @@ <string> "out_in" </string> <real> 305 </real> <real> 402 </real> - <real> 65 </real> + <real> 77 </real> <string> "move" </string> <string> "color" </string> <string> "scale" </string> <string> "rotate" </string> + <string> "callback" </string> <string> "repeat" </string> <string> "pause" </string> <real> 384 </real> @@ -324,9 +326,9 @@ <real> 100 </real> </array> <string> "nodes" </string> - <int_array len="1950"> -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 </int_array> + <int_array len="2013"> -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 </int_array> <string> "conns" </string> - <int_array len="12"> 30, 0, 103, 102, 2, 0, 33, 0, 105, 104, 2, 0 </int_array> + <int_array len="12"> 31, 0, 104, 103, 2, 0, 34, 0, 106, 105, 2, 0 </int_array> </dictionary> </main_resource> 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<InterpolateData>::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<InterpolateData>::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<InterpolateData>::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<InterpolateData>::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<InterpolateData>::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<InterpolateData>::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<PropertyInfo> props; - obj->get_property_list(&props); + p_node->get_property_list(&props); for(List<PropertyInfo>::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(); }; |