Tween.xml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="Tween" inherits="Node" category="Core" version="3.0.alpha.custom_build">
  3. <brief_description>
  4. Node useful for animations with unknown start and end points.
  5. </brief_description>
  6. <description>
  7. Node useful for animations with unknown start and end points, procedural animations, making one node follow another, and other simple behavior.
  8. Because it is easy to get it wrong, here is a quick usage example:
  9. [codeblock]
  10. var tween = get_node("Tween")
  11. tween.interpolate_property(get_node("Node2D_to_move"), "transform/origin", Vector2(0,0), Vector2(100,100), 1, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
  12. tween.start()
  13. [/codeblock]
  14. Some of the methods of this class require a property name. You can get the property name by hovering over the property in the inspector of the editor.
  15. Many of the methods accept [code]trans_type[/code] and [code]ease_type[/code]. The first accepts an TRANS_* constant, and refers to the way the timing of the animation is handled (you might want to see [code]http://easings.net/[/code] for some examples). The second accepts an EASE_* constant, and controls the where [code]trans_type[/code] is applied to the interpolation (in the beginning, the end, or both). If you don't know which transition and easing to pick, you can try different TRANS_* constants with EASE_IN_OUT, and use the one that looks best.
  16. </description>
  17. <tutorials>
  18. </tutorials>
  19. <demos>
  20. </demos>
  21. <methods>
  22. <method name="follow_method">
  23. <return type="bool">
  24. </return>
  25. <argument index="0" name="object" type="Object">
  26. </argument>
  27. <argument index="1" name="method" type="String">
  28. </argument>
  29. <argument index="2" name="initial_val" type="Variant">
  30. </argument>
  31. <argument index="3" name="target" type="Object">
  32. </argument>
  33. <argument index="4" name="target_method" type="String">
  34. </argument>
  35. <argument index="5" name="duration" type="float">
  36. </argument>
  37. <argument index="6" name="trans_type" type="int" enum="Tween.TransitionType">
  38. </argument>
  39. <argument index="7" name="ease_type" type="int" enum="Tween.EaseType">
  40. </argument>
  41. <argument index="8" name="delay" type="float" default="0">
  42. </argument>
  43. <description>
  44. Follow [code]method[/code] of [code]object[/code] and apply the returned value on [code]target_method[/code] of [code]target[/code], beginning from [code]initial_val[/code] for [code]duration[/code] seconds, [code]delay[/code] later. Methods are animated by calling them with consequitive values.
  45. [code]trans_type[/code] accepts TRANS_* constants, and is the way the animation is interpolated, while [code]ease_type[/code] accepts EASE_* constants, and controls the place of the interpolation (the beginning, the end, or both). You can read more about them in the class description.
  46. </description>
  47. </method>
  48. <method name="follow_property">
  49. <return type="bool">
  50. </return>
  51. <argument index="0" name="object" type="Object">
  52. </argument>
  53. <argument index="1" name="property" type="String">
  54. </argument>
  55. <argument index="2" name="initial_val" type="Variant">
  56. </argument>
  57. <argument index="3" name="target" type="Object">
  58. </argument>
  59. <argument index="4" name="target_property" type="String">
  60. </argument>
  61. <argument index="5" name="duration" type="float">
  62. </argument>
  63. <argument index="6" name="trans_type" type="int" enum="Tween.TransitionType">
  64. </argument>
  65. <argument index="7" name="ease_type" type="int" enum="Tween.EaseType">
  66. </argument>
  67. <argument index="8" name="delay" type="float" default="0">
  68. </argument>
  69. <description>
  70. Follow [code]property[/code] of [code]object[/code] and apply it on [code]target_property[/code] of [code]target[/code], beginning from [code]initial_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later. Note that [code]target:target_property[/code] would equal [code]object:property[/code] at the end of the tween.
  71. [code]trans_type[/code] accepts TRANS_* constants, and is the way the animation is interpolated, while [code]ease_type[/code] accepts EASE_* constants, and controls the place of the interpolation (the beginning, the end, or both). You can read more about them in the class description.
  72. </description>
  73. </method>
  74. <method name="get_runtime" qualifiers="const">
  75. <return type="float">
  76. </return>
  77. <description>
  78. Returns the time needed for all tweens to end in seconds, measured from the start. Thus, if you have two tweens, one ending 10 seconds after the start and the other - 20 seconds, it would return 20 seconds, as by that time all tweens would have finished.
  79. </description>
  80. </method>
  81. <method name="get_speed_scale" qualifiers="const">
  82. <return type="float">
  83. </return>
  84. <description>
  85. Returns the speed that has been set from editor GUI or [method set_repeat].
  86. </description>
  87. </method>
  88. <method name="get_tween_process_mode" qualifiers="const">
  89. <return type="int" enum="Tween.TweenProcessMode">
  90. </return>
  91. <description>
  92. Returns the process mode that has been set from editor GUI or [method set_tween_process_mode]
  93. </description>
  94. </method>
  95. <method name="interpolate_callback">
  96. <return type="bool">
  97. </return>
  98. <argument index="0" name="object" type="Object">
  99. </argument>
  100. <argument index="1" name="duration" type="float">
  101. </argument>
  102. <argument index="2" name="callback" type="String">
  103. </argument>
  104. <argument index="3" name="arg1" type="Variant" default="null">
  105. </argument>
  106. <argument index="4" name="arg2" type="Variant" default="null">
  107. </argument>
  108. <argument index="5" name="arg3" type="Variant" default="null">
  109. </argument>
  110. <argument index="6" name="arg4" type="Variant" default="null">
  111. </argument>
  112. <argument index="7" name="arg5" type="Variant" default="null">
  113. </argument>
  114. <description>
  115. Call [code]callback[/code] of [code]object[/code] after [code]duration[/code]. [code]arg1[/code]-[code]arg5[/code] are arguments to be passed to the callback.
  116. </description>
  117. </method>
  118. <method name="interpolate_deferred_callback">
  119. <return type="bool">
  120. </return>
  121. <argument index="0" name="object" type="Object">
  122. </argument>
  123. <argument index="1" name="duration" type="float">
  124. </argument>
  125. <argument index="2" name="callback" type="String">
  126. </argument>
  127. <argument index="3" name="arg1" type="Variant" default="null">
  128. </argument>
  129. <argument index="4" name="arg2" type="Variant" default="null">
  130. </argument>
  131. <argument index="5" name="arg3" type="Variant" default="null">
  132. </argument>
  133. <argument index="6" name="arg4" type="Variant" default="null">
  134. </argument>
  135. <argument index="7" name="arg5" type="Variant" default="null">
  136. </argument>
  137. <description>
  138. Call [code]callback[/code] of [code]object[/code] after [code]duration[/code] on the main thread (similar to [method Object.call_deferred]). [code]arg1[/code]-[code]arg5[/code] are arguments to be passed to the callback.
  139. </description>
  140. </method>
  141. <method name="interpolate_method">
  142. <return type="bool">
  143. </return>
  144. <argument index="0" name="object" type="Object">
  145. </argument>
  146. <argument index="1" name="method" type="String">
  147. </argument>
  148. <argument index="2" name="initial_val" type="Variant">
  149. </argument>
  150. <argument index="3" name="final_val" type="Variant">
  151. </argument>
  152. <argument index="4" name="duration" type="float">
  153. </argument>
  154. <argument index="5" name="trans_type" type="int" enum="Tween.TransitionType">
  155. </argument>
  156. <argument index="6" name="ease_type" type="int" enum="Tween.EaseType">
  157. </argument>
  158. <argument index="7" name="delay" type="float" default="0">
  159. </argument>
  160. <description>
  161. Animate [code]method[/code] of [code]object[/code] from [code]initial_val[/code] to [code]final_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later. Methods are animated by calling them with consecutive values.
  162. [code]trans_type[/code] accepts TRANS_* constants, and is the way the animation is interpolated, while [code]ease_type[/code] accepts EASE_* constants, and controls the place of the interpolation (the beginning, the end, or both). You can read more about them in the class description.
  163. </description>
  164. </method>
  165. <method name="interpolate_property">
  166. <return type="bool">
  167. </return>
  168. <argument index="0" name="object" type="Object">
  169. </argument>
  170. <argument index="1" name="property" type="String">
  171. </argument>
  172. <argument index="2" name="initial_val" type="Variant">
  173. </argument>
  174. <argument index="3" name="final_val" type="Variant">
  175. </argument>
  176. <argument index="4" name="duration" type="float">
  177. </argument>
  178. <argument index="5" name="trans_type" type="int" enum="Tween.TransitionType">
  179. </argument>
  180. <argument index="6" name="ease_type" type="int" enum="Tween.EaseType">
  181. </argument>
  182. <argument index="7" name="delay" type="float" default="0">
  183. </argument>
  184. <description>
  185. Animate [code]property[/code] of [code]object[/code] from [code]initial_val[/code] to [code]final_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later.
  186. [code]trans_type[/code] accepts TRANS_* constants, and is the way the animation is interpolated, while [code]ease_type[/code] accepts EASE_* constants, and controls the place of the interpolation (the beginning, the end, or both). You can read more about them in the class description.
  187. </description>
  188. </method>
  189. <method name="is_active" qualifiers="const">
  190. <return type="bool">
  191. </return>
  192. <description>
  193. Returns true if any tweens are currently running, and false otherwise. Note that this method doesn't consider tweens that have ended.
  194. </description>
  195. </method>
  196. <method name="is_repeat" qualifiers="const">
  197. <return type="bool">
  198. </return>
  199. <description>
  200. Returns true if repeat has been set from editor GUI or [method set_repeat].
  201. </description>
  202. </method>
  203. <method name="remove">
  204. <return type="bool">
  205. </return>
  206. <argument index="0" name="object" type="Object">
  207. </argument>
  208. <argument index="1" name="key" type="String" default="&quot;&quot;">
  209. </argument>
  210. <description>
  211. Stop animating and completely remove a tween, given its object and property/method pair. Passing empty String as key will remove all tweens for given object.
  212. </description>
  213. </method>
  214. <method name="remove_all">
  215. <return type="bool">
  216. </return>
  217. <description>
  218. Stop animating and completely remove all tweens.
  219. </description>
  220. </method>
  221. <method name="reset">
  222. <return type="bool">
  223. </return>
  224. <argument index="0" name="object" type="Object">
  225. </argument>
  226. <argument index="1" name="key" type="String" default="&quot;&quot;">
  227. </argument>
  228. <description>
  229. Resets a tween to the initial value (the one given, not the one before the tween), given its object and property/method pair. Passing empty String as key will reset all tweens for given object.
  230. </description>
  231. </method>
  232. <method name="reset_all">
  233. <return type="bool">
  234. </return>
  235. <description>
  236. Resets all tweens to their initial values (the ones given, not those before the tween).
  237. </description>
  238. </method>
  239. <method name="resume">
  240. <return type="bool">
  241. </return>
  242. <argument index="0" name="object" type="Object">
  243. </argument>
  244. <argument index="1" name="key" type="String" default="&quot;&quot;">
  245. </argument>
  246. <description>
  247. Continue animating a stopped tween, given its object and property/method pair. Passing empty String as key will resume all tweens for given object.
  248. </description>
  249. </method>
  250. <method name="resume_all">
  251. <return type="bool">
  252. </return>
  253. <description>
  254. Continue animating all stopped tweens.
  255. </description>
  256. </method>
  257. <method name="seek">
  258. <return type="bool">
  259. </return>
  260. <argument index="0" name="time" type="float">
  261. </argument>
  262. <description>
  263. Seek the animation to the given [code]time[/code] in seconds.
  264. </description>
  265. </method>
  266. <method name="set_active">
  267. <return type="void">
  268. </return>
  269. <argument index="0" name="active" type="bool">
  270. </argument>
  271. <description>
  272. Activate/deactivate the tween. You can use this for pausing animations, though [method stop_all] and [method resume_all] might be more fit for this.
  273. </description>
  274. </method>
  275. <method name="set_repeat">
  276. <return type="void">
  277. </return>
  278. <argument index="0" name="repeat" type="bool">
  279. </argument>
  280. <description>
  281. Make the tween repeat after all tweens have finished.
  282. </description>
  283. </method>
  284. <method name="set_speed_scale">
  285. <return type="void">
  286. </return>
  287. <argument index="0" name="speed" type="float">
  288. </argument>
  289. <description>
  290. Set the speed multiplier of the tween. Set it to 1 for normal speed, 2 for two times nromal speed, and 0.5 for half of the normal speed. Setting it to 0 would pause the animation, but you might consider using [method set_active] or [method stop_all] and [method resume_all] for this.
  291. </description>
  292. </method>
  293. <method name="set_tween_process_mode">
  294. <return type="void">
  295. </return>
  296. <argument index="0" name="mode" type="int" enum="Tween.TweenProcessMode">
  297. </argument>
  298. <description>
  299. Set whether the Tween uses [code]_process[/code] or [code]_physics_process[/code] (accepts TWEEN_PROCESS_IDLE and TWEEN_PROCESS_PHYSICS constants, respectively).
  300. </description>
  301. </method>
  302. <method name="start">
  303. <return type="bool">
  304. </return>
  305. <description>
  306. Start the tween node. You can define tweens both before and after this.
  307. </description>
  308. </method>
  309. <method name="stop">
  310. <return type="bool">
  311. </return>
  312. <argument index="0" name="object" type="Object">
  313. </argument>
  314. <argument index="1" name="key" type="String" default="&quot;&quot;">
  315. </argument>
  316. <description>
  317. Stop animating a tween, given its object and property/method pair. Passing empty String as key will stop all tweens for given object.
  318. </description>
  319. </method>
  320. <method name="stop_all">
  321. <return type="bool">
  322. </return>
  323. <description>
  324. Stop animating all tweens.
  325. </description>
  326. </method>
  327. <method name="targeting_method">
  328. <return type="bool">
  329. </return>
  330. <argument index="0" name="object" type="Object">
  331. </argument>
  332. <argument index="1" name="method" type="String">
  333. </argument>
  334. <argument index="2" name="initial" type="Object">
  335. </argument>
  336. <argument index="3" name="initial_method" type="String">
  337. </argument>
  338. <argument index="4" name="final_val" type="Variant">
  339. </argument>
  340. <argument index="5" name="duration" type="float">
  341. </argument>
  342. <argument index="6" name="trans_type" type="int" enum="Tween.TransitionType">
  343. </argument>
  344. <argument index="7" name="ease_type" type="int" enum="Tween.EaseType">
  345. </argument>
  346. <argument index="8" name="delay" type="float" default="0">
  347. </argument>
  348. <description>
  349. Animate [code]method[/code] of [code]object[/code] from the value returned by [code]initial.initial_method[/code] to [code]final_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later. Methods are animated by calling them with consecutive values.
  350. [code]trans_type[/code] accepts TRANS_* constants, and is the way the animation is interpolated, while [code]ease_type[/code] accepts EASE_* constants, and controls the place of the interpolation (the beginning, the end, or both). You can read more about them in the class description.
  351. </description>
  352. </method>
  353. <method name="targeting_property">
  354. <return type="bool">
  355. </return>
  356. <argument index="0" name="object" type="Object">
  357. </argument>
  358. <argument index="1" name="property" type="String">
  359. </argument>
  360. <argument index="2" name="initial" type="Object">
  361. </argument>
  362. <argument index="3" name="initial_val" type="String">
  363. </argument>
  364. <argument index="4" name="final_val" type="Variant">
  365. </argument>
  366. <argument index="5" name="duration" type="float">
  367. </argument>
  368. <argument index="6" name="trans_type" type="int" enum="Tween.TransitionType">
  369. </argument>
  370. <argument index="7" name="ease_type" type="int" enum="Tween.EaseType">
  371. </argument>
  372. <argument index="8" name="delay" type="float" default="0">
  373. </argument>
  374. <description>
  375. Animate [code]property[/code] of [code]object[/code] from the current value of the [code]initial_val[/code] property of [code]initial[/code] to [code]final_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later.
  376. [code]trans_type[/code] accepts TRANS_* constants, and is the way the animation is interpolated, while [code]ease_type[/code] accepts EASE_* constants, and controls the place of the interpolation (the beginning, the end, or both). You can read more about them in the class description.
  377. </description>
  378. </method>
  379. <method name="tell" qualifiers="const">
  380. <return type="float">
  381. </return>
  382. <description>
  383. Returns the current time of the tween.
  384. </description>
  385. </method>
  386. </methods>
  387. <members>
  388. <member name="playback_process_mode" type="int" setter="set_tween_process_mode" getter="get_tween_process_mode" enum="Tween.TweenProcessMode">
  389. </member>
  390. </members>
  391. <signals>
  392. <signal name="tween_completed">
  393. <argument index="0" name="object" type="Object">
  394. </argument>
  395. <argument index="1" name="key" type="String">
  396. </argument>
  397. <description>
  398. This signal is emitted when a tween ends.
  399. </description>
  400. </signal>
  401. <signal name="tween_started">
  402. <argument index="0" name="object" type="Object">
  403. </argument>
  404. <argument index="1" name="key" type="String">
  405. </argument>
  406. <description>
  407. This signal is emitted when a tween starts.
  408. </description>
  409. </signal>
  410. <signal name="tween_step">
  411. <argument index="0" name="object" type="Object">
  412. </argument>
  413. <argument index="1" name="key" type="String">
  414. </argument>
  415. <argument index="2" name="elapsed" type="float">
  416. </argument>
  417. <argument index="3" name="value" type="Object">
  418. </argument>
  419. <description>
  420. This signal is emitted each step of the tweening.
  421. </description>
  422. </signal>
  423. </signals>
  424. <constants>
  425. <constant name="TWEEN_PROCESS_PHYSICS" value="0">
  426. The [code]Tween[/code] should use [code]_physics_process[/code] for timekeeping when this is enabled.
  427. </constant>
  428. <constant name="TWEEN_PROCESS_IDLE" value="1">
  429. The [code]Tween[/code] should use [code]_process[/code] for timekeeping when this is enabled (default).
  430. </constant>
  431. <constant name="TRANS_LINEAR" value="0">
  432. Means that the animation is interpolated linearly.
  433. </constant>
  434. <constant name="TRANS_SINE" value="1">
  435. Means that the animation is interpolated using a sine wave.
  436. </constant>
  437. <constant name="TRANS_QUINT" value="2">
  438. Means that the animation is interpolated with a quinary (to the power of 5) function.
  439. </constant>
  440. <constant name="TRANS_QUART" value="3">
  441. Means that the animation is interpolated with a quartic (to the power of 4) function.
  442. </constant>
  443. <constant name="TRANS_QUAD" value="4">
  444. Means that the animation is interpolated with a quadratic (to the power of 2) function.
  445. </constant>
  446. <constant name="TRANS_EXPO" value="5">
  447. Means that the animation is interpolated with an exponential (some number to the power of x) function.
  448. </constant>
  449. <constant name="TRANS_ELASTIC" value="6">
  450. Means that the animation is interpolated with elasticity, wiggling around the edges.
  451. </constant>
  452. <constant name="TRANS_CUBIC" value="7">
  453. Means that the animation is interpolated with a cubic (to the power of 3) function.
  454. </constant>
  455. <constant name="TRANS_CIRC" value="8">
  456. Means that the animation is interpolated with a function using square roots.
  457. </constant>
  458. <constant name="TRANS_BOUNCE" value="9">
  459. Means that the animation is interpolated by bouncing at, but never surpassing, the end.
  460. </constant>
  461. <constant name="TRANS_BACK" value="10">
  462. Means that the animation is interpolated backing out at edges.
  463. </constant>
  464. <constant name="EASE_IN" value="0">
  465. Signifies that the interpolation should be focused in the beginning.
  466. </constant>
  467. <constant name="EASE_OUT" value="1">
  468. Signifies that the interpolation should be focused in the end.
  469. </constant>
  470. <constant name="EASE_IN_OUT" value="2">
  471. Signifies that the interpolation should be focused in both ends.
  472. </constant>
  473. <constant name="EASE_OUT_IN" value="3">
  474. Signifies that the interpolation should be focused in both ends, but they should be switched (a bit hard to explain, try it for yourself to be sure).
  475. </constant>
  476. </constants>
  477. </class>