class_animatedsprite3d.rst 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/AnimatedSprite3D.xml.
  6. .. _class_AnimatedSprite3D:
  7. AnimatedSprite3D
  8. ================
  9. **Inherits:** :ref:`SpriteBase3D<class_SpriteBase3D>` **<** :ref:`GeometryInstance3D<class_GeometryInstance3D>` **<** :ref:`VisualInstance3D<class_VisualInstance3D>` **<** :ref:`Node3D<class_Node3D>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. 2D sprite node in 3D world, that can use multiple 2D textures for animation.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. **AnimatedSprite3D** is similar to the :ref:`Sprite3D<class_Sprite3D>` node, except it carries multiple textures as animation :ref:`sprite_frames<class_AnimatedSprite3D_property_sprite_frames>`. Animations are created using a :ref:`SpriteFrames<class_SpriteFrames>` resource, which allows you to import image files (or a folder containing said files) to provide the animation frames for the sprite. The :ref:`SpriteFrames<class_SpriteFrames>` resource can be configured in the editor via the SpriteFrames bottom panel.
  15. .. rst-class:: classref-introduction-group
  16. Tutorials
  17. ---------
  18. - :doc:`2D Sprite animation (also applies to 3D) <../tutorials/2d/2d_sprite_animation>`
  19. .. rst-class:: classref-reftable-group
  20. Properties
  21. ----------
  22. .. table::
  23. :widths: auto
  24. +-----------------------------------------+-----------------------------------------------------------------------+----------------+
  25. | :ref:`StringName<class_StringName>` | :ref:`animation<class_AnimatedSprite3D_property_animation>` | ``&"default"`` |
  26. +-----------------------------------------+-----------------------------------------------------------------------+----------------+
  27. | :ref:`String<class_String>` | :ref:`autoplay<class_AnimatedSprite3D_property_autoplay>` | ``""`` |
  28. +-----------------------------------------+-----------------------------------------------------------------------+----------------+
  29. | :ref:`int<class_int>` | :ref:`frame<class_AnimatedSprite3D_property_frame>` | ``0`` |
  30. +-----------------------------------------+-----------------------------------------------------------------------+----------------+
  31. | :ref:`float<class_float>` | :ref:`frame_progress<class_AnimatedSprite3D_property_frame_progress>` | ``0.0`` |
  32. +-----------------------------------------+-----------------------------------------------------------------------+----------------+
  33. | :ref:`float<class_float>` | :ref:`speed_scale<class_AnimatedSprite3D_property_speed_scale>` | ``1.0`` |
  34. +-----------------------------------------+-----------------------------------------------------------------------+----------------+
  35. | :ref:`SpriteFrames<class_SpriteFrames>` | :ref:`sprite_frames<class_AnimatedSprite3D_property_sprite_frames>` | |
  36. +-----------------------------------------+-----------------------------------------------------------------------+----------------+
  37. .. rst-class:: classref-reftable-group
  38. Methods
  39. -------
  40. .. table::
  41. :widths: auto
  42. +---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`float<class_float>` | :ref:`get_playing_speed<class_AnimatedSprite3D_method_get_playing_speed>`\ (\ ) |const| |
  44. +---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`bool<class_bool>` | :ref:`is_playing<class_AnimatedSprite3D_method_is_playing>`\ (\ ) |const| |
  46. +---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | |void| | :ref:`pause<class_AnimatedSprite3D_method_pause>`\ (\ ) |
  48. +---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | |void| | :ref:`play<class_AnimatedSprite3D_method_play>`\ (\ name\: :ref:`StringName<class_StringName>` = &"", custom_speed\: :ref:`float<class_float>` = 1.0, from_end\: :ref:`bool<class_bool>` = false\ ) |
  50. +---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | |void| | :ref:`play_backwards<class_AnimatedSprite3D_method_play_backwards>`\ (\ name\: :ref:`StringName<class_StringName>` = &""\ ) |
  52. +---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | |void| | :ref:`set_frame_and_progress<class_AnimatedSprite3D_method_set_frame_and_progress>`\ (\ frame\: :ref:`int<class_int>`, progress\: :ref:`float<class_float>`\ ) |
  54. +---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | |void| | :ref:`stop<class_AnimatedSprite3D_method_stop>`\ (\ ) |
  56. +---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. .. rst-class:: classref-section-separator
  58. ----
  59. .. rst-class:: classref-descriptions-group
  60. Signals
  61. -------
  62. .. _class_AnimatedSprite3D_signal_animation_changed:
  63. .. rst-class:: classref-signal
  64. **animation_changed**\ (\ ) :ref:`🔗<class_AnimatedSprite3D_signal_animation_changed>`
  65. Emitted when :ref:`animation<class_AnimatedSprite3D_property_animation>` changes.
  66. .. rst-class:: classref-item-separator
  67. ----
  68. .. _class_AnimatedSprite3D_signal_animation_finished:
  69. .. rst-class:: classref-signal
  70. **animation_finished**\ (\ ) :ref:`🔗<class_AnimatedSprite3D_signal_animation_finished>`
  71. Emitted when the animation reaches the end, or the start if it is played in reverse. When the animation finishes, it pauses the playback.
  72. \ **Note:** This signal is not emitted if an animation is looping.
  73. .. rst-class:: classref-item-separator
  74. ----
  75. .. _class_AnimatedSprite3D_signal_animation_looped:
  76. .. rst-class:: classref-signal
  77. **animation_looped**\ (\ ) :ref:`🔗<class_AnimatedSprite3D_signal_animation_looped>`
  78. Emitted when the animation loops.
  79. .. rst-class:: classref-item-separator
  80. ----
  81. .. _class_AnimatedSprite3D_signal_frame_changed:
  82. .. rst-class:: classref-signal
  83. **frame_changed**\ (\ ) :ref:`🔗<class_AnimatedSprite3D_signal_frame_changed>`
  84. Emitted when :ref:`frame<class_AnimatedSprite3D_property_frame>` changes.
  85. .. rst-class:: classref-item-separator
  86. ----
  87. .. _class_AnimatedSprite3D_signal_sprite_frames_changed:
  88. .. rst-class:: classref-signal
  89. **sprite_frames_changed**\ (\ ) :ref:`🔗<class_AnimatedSprite3D_signal_sprite_frames_changed>`
  90. Emitted when :ref:`sprite_frames<class_AnimatedSprite3D_property_sprite_frames>` changes.
  91. .. rst-class:: classref-section-separator
  92. ----
  93. .. rst-class:: classref-descriptions-group
  94. Property Descriptions
  95. ---------------------
  96. .. _class_AnimatedSprite3D_property_animation:
  97. .. rst-class:: classref-property
  98. :ref:`StringName<class_StringName>` **animation** = ``&"default"`` :ref:`🔗<class_AnimatedSprite3D_property_animation>`
  99. .. rst-class:: classref-property-setget
  100. - |void| **set_animation**\ (\ value\: :ref:`StringName<class_StringName>`\ )
  101. - :ref:`StringName<class_StringName>` **get_animation**\ (\ )
  102. The current animation from the :ref:`sprite_frames<class_AnimatedSprite3D_property_sprite_frames>` resource. If this value is changed, the :ref:`frame<class_AnimatedSprite3D_property_frame>` counter and the :ref:`frame_progress<class_AnimatedSprite3D_property_frame_progress>` are reset.
  103. .. rst-class:: classref-item-separator
  104. ----
  105. .. _class_AnimatedSprite3D_property_autoplay:
  106. .. rst-class:: classref-property
  107. :ref:`String<class_String>` **autoplay** = ``""`` :ref:`🔗<class_AnimatedSprite3D_property_autoplay>`
  108. .. rst-class:: classref-property-setget
  109. - |void| **set_autoplay**\ (\ value\: :ref:`String<class_String>`\ )
  110. - :ref:`String<class_String>` **get_autoplay**\ (\ )
  111. The key of the animation to play when the scene loads.
  112. .. rst-class:: classref-item-separator
  113. ----
  114. .. _class_AnimatedSprite3D_property_frame:
  115. .. rst-class:: classref-property
  116. :ref:`int<class_int>` **frame** = ``0`` :ref:`🔗<class_AnimatedSprite3D_property_frame>`
  117. .. rst-class:: classref-property-setget
  118. - |void| **set_frame**\ (\ value\: :ref:`int<class_int>`\ )
  119. - :ref:`int<class_int>` **get_frame**\ (\ )
  120. The displayed animation frame's index. Setting this property also resets :ref:`frame_progress<class_AnimatedSprite3D_property_frame_progress>`. If this is not desired, use :ref:`set_frame_and_progress<class_AnimatedSprite3D_method_set_frame_and_progress>`.
  121. .. rst-class:: classref-item-separator
  122. ----
  123. .. _class_AnimatedSprite3D_property_frame_progress:
  124. .. rst-class:: classref-property
  125. :ref:`float<class_float>` **frame_progress** = ``0.0`` :ref:`🔗<class_AnimatedSprite3D_property_frame_progress>`
  126. .. rst-class:: classref-property-setget
  127. - |void| **set_frame_progress**\ (\ value\: :ref:`float<class_float>`\ )
  128. - :ref:`float<class_float>` **get_frame_progress**\ (\ )
  129. The progress value between ``0.0`` and ``1.0`` until the current frame transitions to the next frame. If the animation is playing backwards, the value transitions from ``1.0`` to ``0.0``.
  130. .. rst-class:: classref-item-separator
  131. ----
  132. .. _class_AnimatedSprite3D_property_speed_scale:
  133. .. rst-class:: classref-property
  134. :ref:`float<class_float>` **speed_scale** = ``1.0`` :ref:`🔗<class_AnimatedSprite3D_property_speed_scale>`
  135. .. rst-class:: classref-property-setget
  136. - |void| **set_speed_scale**\ (\ value\: :ref:`float<class_float>`\ )
  137. - :ref:`float<class_float>` **get_speed_scale**\ (\ )
  138. The speed scaling ratio. For example, if this value is ``1``, then the animation plays at normal speed. If it's ``0.5``, then it plays at half speed. If it's ``2``, then it plays at double speed.
  139. If set to a negative value, the animation is played in reverse. If set to ``0``, the animation will not advance.
  140. .. rst-class:: classref-item-separator
  141. ----
  142. .. _class_AnimatedSprite3D_property_sprite_frames:
  143. .. rst-class:: classref-property
  144. :ref:`SpriteFrames<class_SpriteFrames>` **sprite_frames** :ref:`🔗<class_AnimatedSprite3D_property_sprite_frames>`
  145. .. rst-class:: classref-property-setget
  146. - |void| **set_sprite_frames**\ (\ value\: :ref:`SpriteFrames<class_SpriteFrames>`\ )
  147. - :ref:`SpriteFrames<class_SpriteFrames>` **get_sprite_frames**\ (\ )
  148. The :ref:`SpriteFrames<class_SpriteFrames>` resource containing the animation(s). Allows you the option to load, edit, clear, make unique and save the states of the :ref:`SpriteFrames<class_SpriteFrames>` resource.
  149. .. rst-class:: classref-section-separator
  150. ----
  151. .. rst-class:: classref-descriptions-group
  152. Method Descriptions
  153. -------------------
  154. .. _class_AnimatedSprite3D_method_get_playing_speed:
  155. .. rst-class:: classref-method
  156. :ref:`float<class_float>` **get_playing_speed**\ (\ ) |const| :ref:`🔗<class_AnimatedSprite3D_method_get_playing_speed>`
  157. Returns the actual playing speed of current animation or ``0`` if not playing. This speed is the :ref:`speed_scale<class_AnimatedSprite3D_property_speed_scale>` property multiplied by ``custom_speed`` argument specified when calling the :ref:`play<class_AnimatedSprite3D_method_play>` method.
  158. Returns a negative value if the current animation is playing backwards.
  159. .. rst-class:: classref-item-separator
  160. ----
  161. .. _class_AnimatedSprite3D_method_is_playing:
  162. .. rst-class:: classref-method
  163. :ref:`bool<class_bool>` **is_playing**\ (\ ) |const| :ref:`🔗<class_AnimatedSprite3D_method_is_playing>`
  164. Returns ``true`` if an animation is currently playing (even if :ref:`speed_scale<class_AnimatedSprite3D_property_speed_scale>` and/or ``custom_speed`` are ``0``).
  165. .. rst-class:: classref-item-separator
  166. ----
  167. .. _class_AnimatedSprite3D_method_pause:
  168. .. rst-class:: classref-method
  169. |void| **pause**\ (\ ) :ref:`🔗<class_AnimatedSprite3D_method_pause>`
  170. Pauses the currently playing animation. The :ref:`frame<class_AnimatedSprite3D_property_frame>` and :ref:`frame_progress<class_AnimatedSprite3D_property_frame_progress>` will be kept and calling :ref:`play<class_AnimatedSprite3D_method_play>` or :ref:`play_backwards<class_AnimatedSprite3D_method_play_backwards>` without arguments will resume the animation from the current playback position.
  171. See also :ref:`stop<class_AnimatedSprite3D_method_stop>`.
  172. .. rst-class:: classref-item-separator
  173. ----
  174. .. _class_AnimatedSprite3D_method_play:
  175. .. rst-class:: classref-method
  176. |void| **play**\ (\ name\: :ref:`StringName<class_StringName>` = &"", custom_speed\: :ref:`float<class_float>` = 1.0, from_end\: :ref:`bool<class_bool>` = false\ ) :ref:`🔗<class_AnimatedSprite3D_method_play>`
  177. Plays the animation with key ``name``. If ``custom_speed`` is negative and ``from_end`` is ``true``, the animation will play backwards (which is equivalent to calling :ref:`play_backwards<class_AnimatedSprite3D_method_play_backwards>`).
  178. If this method is called with that same animation ``name``, or with no ``name`` parameter, the assigned animation will resume playing if it was paused.
  179. .. rst-class:: classref-item-separator
  180. ----
  181. .. _class_AnimatedSprite3D_method_play_backwards:
  182. .. rst-class:: classref-method
  183. |void| **play_backwards**\ (\ name\: :ref:`StringName<class_StringName>` = &""\ ) :ref:`🔗<class_AnimatedSprite3D_method_play_backwards>`
  184. Plays the animation with key ``name`` in reverse.
  185. This method is a shorthand for :ref:`play<class_AnimatedSprite3D_method_play>` with ``custom_speed = -1.0`` and ``from_end = true``, so see its description for more information.
  186. .. rst-class:: classref-item-separator
  187. ----
  188. .. _class_AnimatedSprite3D_method_set_frame_and_progress:
  189. .. rst-class:: classref-method
  190. |void| **set_frame_and_progress**\ (\ frame\: :ref:`int<class_int>`, progress\: :ref:`float<class_float>`\ ) :ref:`🔗<class_AnimatedSprite3D_method_set_frame_and_progress>`
  191. Sets :ref:`frame<class_AnimatedSprite3D_property_frame>` the :ref:`frame_progress<class_AnimatedSprite3D_property_frame_progress>` to the given values. Unlike setting :ref:`frame<class_AnimatedSprite3D_property_frame>`, this method does not reset the :ref:`frame_progress<class_AnimatedSprite3D_property_frame_progress>` to ``0.0`` implicitly.
  192. \ **Example:** Change the animation while keeping the same :ref:`frame<class_AnimatedSprite3D_property_frame>` and :ref:`frame_progress<class_AnimatedSprite3D_property_frame_progress>`:
  193. .. tabs::
  194. .. code-tab:: gdscript
  195. var current_frame = animated_sprite.get_frame()
  196. var current_progress = animated_sprite.get_frame_progress()
  197. animated_sprite.play("walk_another_skin")
  198. animated_sprite.set_frame_and_progress(current_frame, current_progress)
  199. .. rst-class:: classref-item-separator
  200. ----
  201. .. _class_AnimatedSprite3D_method_stop:
  202. .. rst-class:: classref-method
  203. |void| **stop**\ (\ ) :ref:`🔗<class_AnimatedSprite3D_method_stop>`
  204. Stops the currently playing animation. The animation position is reset to ``0`` and the ``custom_speed`` is reset to ``1.0``. See also :ref:`pause<class_AnimatedSprite3D_method_pause>`.
  205. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  206. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  207. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  208. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  209. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  210. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  211. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  212. .. |void| replace:: :abbr:`void (No return value.)`