class_animationplayer.rst 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_AnimationPlayer:
  4. AnimationPlayer
  5. ===============
  6. **Inherits:** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  7. **Category:** Core
  8. Brief Description
  9. -----------------
  10. Container and player of :ref:`Animation<class_animation>` resources.
  11. Member Functions
  12. ----------------
  13. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  14. | :ref:`int<class_int>` | :ref:`add_animation<class_AnimationPlayer_add_animation>` **(** :ref:`String<class_string>` name, :ref:`Animation<class_animation>` animation **)** |
  15. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | void | :ref:`advance<class_AnimationPlayer_advance>` **(** :ref:`float<class_float>` delta **)** |
  17. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | :ref:`String<class_string>` | :ref:`animation_get_next<class_AnimationPlayer_animation_get_next>` **(** :ref:`String<class_string>` anim_from **)** const |
  19. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | void | :ref:`animation_set_next<class_AnimationPlayer_animation_set_next>` **(** :ref:`String<class_string>` anim_from, :ref:`String<class_string>` anim_to **)** |
  21. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | void | :ref:`clear_caches<class_AnimationPlayer_clear_caches>` **(** **)** |
  23. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | void | :ref:`clear_queue<class_AnimationPlayer_clear_queue>` **(** **)** |
  25. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`String<class_string>` | :ref:`find_animation<class_AnimationPlayer_find_animation>` **(** :ref:`Animation<class_animation>` animation **)** const |
  27. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`Animation<class_animation>` | :ref:`get_animation<class_AnimationPlayer_get_animation>` **(** :ref:`String<class_string>` name **)** const |
  29. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`StringArray<class_stringarray>` | :ref:`get_animation_list<class_AnimationPlayer_get_animation_list>` **(** **)** const |
  31. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`int<class_int>` | :ref:`get_animation_process_mode<class_AnimationPlayer_get_animation_process_mode>` **(** **)** const |
  33. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`String<class_string>` | :ref:`get_autoplay<class_AnimationPlayer_get_autoplay>` **(** **)** const |
  35. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`float<class_float>` | :ref:`get_blend_time<class_AnimationPlayer_get_blend_time>` **(** :ref:`String<class_string>` anim_from, :ref:`String<class_string>` anim_to **)** const |
  37. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`String<class_string>` | :ref:`get_current_animation<class_AnimationPlayer_get_current_animation>` **(** **)** const |
  39. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`float<class_float>` | :ref:`get_current_animation_length<class_AnimationPlayer_get_current_animation_length>` **(** **)** const |
  41. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`float<class_float>` | :ref:`get_current_animation_pos<class_AnimationPlayer_get_current_animation_pos>` **(** **)** const |
  43. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`float<class_float>` | :ref:`get_default_blend_time<class_AnimationPlayer_get_default_blend_time>` **(** **)** const |
  45. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`float<class_float>` | :ref:`get_pos<class_AnimationPlayer_get_pos>` **(** **)** const |
  47. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`NodePath<class_nodepath>` | :ref:`get_root<class_AnimationPlayer_get_root>` **(** **)** const |
  49. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`float<class_float>` | :ref:`get_speed<class_AnimationPlayer_get_speed>` **(** **)** const |
  51. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`bool<class_bool>` | :ref:`has_animation<class_AnimationPlayer_has_animation>` **(** :ref:`String<class_string>` name **)** const |
  53. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`bool<class_bool>` | :ref:`is_active<class_AnimationPlayer_is_active>` **(** **)** const |
  55. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`bool<class_bool>` | :ref:`is_playing<class_AnimationPlayer_is_playing>` **(** **)** const |
  57. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | void | :ref:`play<class_AnimationPlayer_play>` **(** :ref:`String<class_string>` name="", :ref:`float<class_float>` custom_blend=-1, :ref:`float<class_float>` custom_speed=1, :ref:`bool<class_bool>` from_end=false **)** |
  59. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | void | :ref:`play_backwards<class_AnimationPlayer_play_backwards>` **(** :ref:`String<class_string>` name="", :ref:`float<class_float>` custom_blend=-1 **)** |
  61. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | void | :ref:`queue<class_AnimationPlayer_queue>` **(** :ref:`String<class_string>` name **)** |
  63. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | void | :ref:`remove_animation<class_AnimationPlayer_remove_animation>` **(** :ref:`String<class_string>` name **)** |
  65. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | void | :ref:`rename_animation<class_AnimationPlayer_rename_animation>` **(** :ref:`String<class_string>` name, :ref:`String<class_string>` newname **)** |
  67. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | void | :ref:`seek<class_AnimationPlayer_seek>` **(** :ref:`float<class_float>` pos_sec, :ref:`bool<class_bool>` update=false **)** |
  69. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | void | :ref:`set_active<class_AnimationPlayer_set_active>` **(** :ref:`bool<class_bool>` active **)** |
  71. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | void | :ref:`set_animation_process_mode<class_AnimationPlayer_set_animation_process_mode>` **(** :ref:`int<class_int>` mode **)** |
  73. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | void | :ref:`set_autoplay<class_AnimationPlayer_set_autoplay>` **(** :ref:`String<class_string>` name **)** |
  75. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | void | :ref:`set_blend_time<class_AnimationPlayer_set_blend_time>` **(** :ref:`String<class_string>` anim_from, :ref:`String<class_string>` anim_to, :ref:`float<class_float>` sec **)** |
  77. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | void | :ref:`set_current_animation<class_AnimationPlayer_set_current_animation>` **(** :ref:`String<class_string>` anim **)** |
  79. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | void | :ref:`set_default_blend_time<class_AnimationPlayer_set_default_blend_time>` **(** :ref:`float<class_float>` sec **)** |
  81. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | void | :ref:`set_root<class_AnimationPlayer_set_root>` **(** :ref:`NodePath<class_nodepath>` path **)** |
  83. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | void | :ref:`set_speed<class_AnimationPlayer_set_speed>` **(** :ref:`float<class_float>` speed **)** |
  85. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | void | :ref:`stop<class_AnimationPlayer_stop>` **(** :ref:`bool<class_bool>` reset=true **)** |
  87. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | void | :ref:`stop_all<class_AnimationPlayer_stop_all>` **(** **)** |
  89. +----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. Signals
  91. -------
  92. - **animation_changed** **(** :ref:`String<class_string>` old_name, :ref:`String<class_string>` new_name **)**
  93. If the currently being played animation changes, this signal will notify of such change.
  94. - **animation_started** **(** :ref:`String<class_string>` name **)**
  95. Notifies when an animation starts playing.
  96. - **finished** **(** **)**
  97. Notifies when an animation finished playing.
  98. Numeric Constants
  99. -----------------
  100. - **ANIMATION_PROCESS_FIXED** = **0** --- Process animation on fixed process. This is specially useful when animating kinematic bodies.
  101. - **ANIMATION_PROCESS_IDLE** = **1** --- Process animation on idle process.
  102. Description
  103. -----------
  104. An animation player is used for general purpose playback of :ref:`Animation<class_animation>` resources. It contains a dictionary of animations (referenced by name) and custom blend times between their transitions. Additionally, animations can be played and blended in different channels.
  105. Member Function Description
  106. ---------------------------
  107. .. _class_AnimationPlayer_add_animation:
  108. - :ref:`int<class_int>` **add_animation** **(** :ref:`String<class_string>` name, :ref:`Animation<class_animation>` animation **)**
  109. Add an animation resource to the player, which will be later referenced by the "name" argument.
  110. .. _class_AnimationPlayer_advance:
  111. - void **advance** **(** :ref:`float<class_float>` delta **)**
  112. Used to skip ahead or skip back in an animation. Delta is the time in seconds to skip.
  113. .. _class_AnimationPlayer_animation_get_next:
  114. - :ref:`String<class_string>` **animation_get_next** **(** :ref:`String<class_string>` anim_from **)** const
  115. .. _class_AnimationPlayer_animation_set_next:
  116. - void **animation_set_next** **(** :ref:`String<class_string>` anim_from, :ref:`String<class_string>` anim_to **)**
  117. .. _class_AnimationPlayer_clear_caches:
  118. - void **clear_caches** **(** **)**
  119. The animation player creates caches for faster access to the nodes it will animate. However, if a specific node is removed, it may not notice it, so clear_caches will force the player to search for the nodes again.
  120. .. _class_AnimationPlayer_clear_queue:
  121. - void **clear_queue** **(** **)**
  122. If animations are queued to play, clear them.
  123. .. _class_AnimationPlayer_find_animation:
  124. - :ref:`String<class_string>` **find_animation** **(** :ref:`Animation<class_animation>` animation **)** const
  125. Find an animation name by resource.
  126. .. _class_AnimationPlayer_get_animation:
  127. - :ref:`Animation<class_animation>` **get_animation** **(** :ref:`String<class_string>` name **)** const
  128. Get an :ref:`Animation<class_animation>` resource by requesting a name.
  129. .. _class_AnimationPlayer_get_animation_list:
  130. - :ref:`StringArray<class_stringarray>` **get_animation_list** **(** **)** const
  131. Get the list of names of the animations stored in the player.
  132. .. _class_AnimationPlayer_get_animation_process_mode:
  133. - :ref:`int<class_int>` **get_animation_process_mode** **(** **)** const
  134. Return the mode in which the animation player processes. See :ref:`set_animation_process_mode<class_AnimationPlayer_set_animation_process_mode>`.
  135. .. _class_AnimationPlayer_get_autoplay:
  136. - :ref:`String<class_string>` **get_autoplay** **(** **)** const
  137. Return the name of the animation that will be automatically played when the scene is loaded.
  138. .. _class_AnimationPlayer_get_blend_time:
  139. - :ref:`float<class_float>` **get_blend_time** **(** :ref:`String<class_string>` anim_from, :ref:`String<class_string>` anim_to **)** const
  140. Get the blend time between two animations, referenced by their names.
  141. .. _class_AnimationPlayer_get_current_animation:
  142. - :ref:`String<class_string>` **get_current_animation** **(** **)** const
  143. Return the name of the animation being played.
  144. .. _class_AnimationPlayer_get_current_animation_length:
  145. - :ref:`float<class_float>` **get_current_animation_length** **(** **)** const
  146. Get the length (in seconds) of the currently being played animation.
  147. .. _class_AnimationPlayer_get_current_animation_pos:
  148. - :ref:`float<class_float>` **get_current_animation_pos** **(** **)** const
  149. Get the position (in seconds) of the currently being played animation.
  150. .. _class_AnimationPlayer_get_default_blend_time:
  151. - :ref:`float<class_float>` **get_default_blend_time** **(** **)** const
  152. Return the default blend time between animations.
  153. .. _class_AnimationPlayer_get_pos:
  154. - :ref:`float<class_float>` **get_pos** **(** **)** const
  155. Return the playback position (in seconds) in an animation channel (or channel 0 if none is provided).
  156. .. _class_AnimationPlayer_get_root:
  157. - :ref:`NodePath<class_nodepath>` **get_root** **(** **)** const
  158. Return path to root node (see :ref:`set_root<class_AnimationPlayer_set_root>`).
  159. .. _class_AnimationPlayer_get_speed:
  160. - :ref:`float<class_float>` **get_speed** **(** **)** const
  161. Get the speed scaling ratio in a given animation channel (or channel 0 if none is provided). Default ratio is *1* (no scaling).
  162. .. _class_AnimationPlayer_has_animation:
  163. - :ref:`bool<class_bool>` **has_animation** **(** :ref:`String<class_string>` name **)** const
  164. Request whether an :ref:`Animation<class_animation>` name exist within the player.
  165. .. _class_AnimationPlayer_is_active:
  166. - :ref:`bool<class_bool>` **is_active** **(** **)** const
  167. Return true if the player is active.
  168. .. _class_AnimationPlayer_is_playing:
  169. - :ref:`bool<class_bool>` **is_playing** **(** **)** const
  170. Return whether an animation is playing.
  171. .. _class_AnimationPlayer_play:
  172. - void **play** **(** :ref:`String<class_string>` name="", :ref:`float<class_float>` custom_blend=-1, :ref:`float<class_float>` custom_speed=1, :ref:`bool<class_bool>` from_end=false **)**
  173. Play a given animation by the animation name. Custom speed and blend times can be set. If custom speed is negative (-1), 'from_end' being true can play the animation backwards.
  174. .. _class_AnimationPlayer_play_backwards:
  175. - void **play_backwards** **(** :ref:`String<class_string>` name="", :ref:`float<class_float>` custom_blend=-1 **)**
  176. Play a given animation by the animation name in reverse.
  177. .. _class_AnimationPlayer_queue:
  178. - void **queue** **(** :ref:`String<class_string>` name **)**
  179. Queue an animation for playback once the current one is done.
  180. .. _class_AnimationPlayer_remove_animation:
  181. - void **remove_animation** **(** :ref:`String<class_string>` name **)**
  182. Remove an animation from the player (by supplying the same name used to add it).
  183. .. _class_AnimationPlayer_rename_animation:
  184. - void **rename_animation** **(** :ref:`String<class_string>` name, :ref:`String<class_string>` newname **)**
  185. Rename an existing animation.
  186. .. _class_AnimationPlayer_seek:
  187. - void **seek** **(** :ref:`float<class_float>` pos_sec, :ref:`bool<class_bool>` update=false **)**
  188. Seek the animation to a given position in time (in seconds). If 'update' is true, the animation will be updated too, otherwise it will be updated at process time.
  189. .. _class_AnimationPlayer_set_active:
  190. - void **set_active** **(** :ref:`bool<class_bool>` active **)**
  191. Set the player as active (playing). If false, it will do nothing.
  192. .. _class_AnimationPlayer_set_animation_process_mode:
  193. - void **set_animation_process_mode** **(** :ref:`int<class_int>` mode **)**
  194. Set the mode in which the animation player processes. By default, it processes on idle time (framerate dependent), but using fixed time works well for animating static collision bodies in 2D and 3D. See enum ANIMATION_PROCESS\_\*.
  195. .. _class_AnimationPlayer_set_autoplay:
  196. - void **set_autoplay** **(** :ref:`String<class_string>` name **)**
  197. Set the name of the animation that will be automatically played when the scene is loaded.
  198. .. _class_AnimationPlayer_set_blend_time:
  199. - void **set_blend_time** **(** :ref:`String<class_string>` anim_from, :ref:`String<class_string>` anim_to, :ref:`float<class_float>` sec **)**
  200. Specify a blend time (in seconds) between two animations, referenced by their names.
  201. .. _class_AnimationPlayer_set_current_animation:
  202. - void **set_current_animation** **(** :ref:`String<class_string>` anim **)**
  203. Set the current animation (even if no playback occurs). Using set_current_animation() and set_active() are similar to calling play().
  204. .. _class_AnimationPlayer_set_default_blend_time:
  205. - void **set_default_blend_time** **(** :ref:`float<class_float>` sec **)**
  206. Set the default blend time between animations.
  207. .. _class_AnimationPlayer_set_root:
  208. - void **set_root** **(** :ref:`NodePath<class_nodepath>` path **)**
  209. AnimationPlayer resolves animation track paths from this node (which is relative to itself), by default root is "..", but it can be changed.
  210. .. _class_AnimationPlayer_set_speed:
  211. - void **set_speed** **(** :ref:`float<class_float>` speed **)**
  212. Set a speed scaling ratio in a given animation channel (or channel 0 if none is provided). Default ratio is *1* (no scaling).
  213. .. _class_AnimationPlayer_stop:
  214. - void **stop** **(** :ref:`bool<class_bool>` reset=true **)**
  215. Stop the currently playing animation.
  216. .. _class_AnimationPlayer_stop_all:
  217. - void **stop_all** **(** **)**
  218. Stop playback of animations (deprecated).