class_animatedsprite3d.rst 16 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/4.2/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.2/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>` **(** :ref:`StringName<class_StringName>` name=&"", :ref:`float<class_float>` custom_speed=1.0, :ref:`bool<class_bool>` from_end=false **)** |
  50. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | void | :ref:`play_backwards<class_AnimatedSprite3D_method_play_backwards>` **(** :ref:`StringName<class_StringName>` name=&"" **)** |
  52. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | void | :ref:`set_frame_and_progress<class_AnimatedSprite3D_method_set_frame_and_progress>` **(** :ref:`int<class_int>` frame, :ref:`float<class_float>` progress **)** |
  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** **(** **)**
  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** **(** **)**
  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. .. rst-class:: classref-item-separator
  73. ----
  74. .. _class_AnimatedSprite3D_signal_animation_looped:
  75. .. rst-class:: classref-signal
  76. **animation_looped** **(** **)**
  77. Emitted when the animation loops.
  78. .. rst-class:: classref-item-separator
  79. ----
  80. .. _class_AnimatedSprite3D_signal_frame_changed:
  81. .. rst-class:: classref-signal
  82. **frame_changed** **(** **)**
  83. Emitted when :ref:`frame<class_AnimatedSprite3D_property_frame>` changes.
  84. .. rst-class:: classref-item-separator
  85. ----
  86. .. _class_AnimatedSprite3D_signal_sprite_frames_changed:
  87. .. rst-class:: classref-signal
  88. **sprite_frames_changed** **(** **)**
  89. Emitted when :ref:`sprite_frames<class_AnimatedSprite3D_property_sprite_frames>` changes.
  90. .. rst-class:: classref-section-separator
  91. ----
  92. .. rst-class:: classref-descriptions-group
  93. Property Descriptions
  94. ---------------------
  95. .. _class_AnimatedSprite3D_property_animation:
  96. .. rst-class:: classref-property
  97. :ref:`StringName<class_StringName>` **animation** = ``&"default"``
  98. .. rst-class:: classref-property-setget
  99. - void **set_animation** **(** :ref:`StringName<class_StringName>` value **)**
  100. - :ref:`StringName<class_StringName>` **get_animation** **(** **)**
  101. 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.
  102. .. rst-class:: classref-item-separator
  103. ----
  104. .. _class_AnimatedSprite3D_property_autoplay:
  105. .. rst-class:: classref-property
  106. :ref:`String<class_String>` **autoplay** = ``""``
  107. .. rst-class:: classref-property-setget
  108. - void **set_autoplay** **(** :ref:`String<class_String>` value **)**
  109. - :ref:`String<class_String>` **get_autoplay** **(** **)**
  110. The key of the animation to play when the scene loads.
  111. .. rst-class:: classref-item-separator
  112. ----
  113. .. _class_AnimatedSprite3D_property_frame:
  114. .. rst-class:: classref-property
  115. :ref:`int<class_int>` **frame** = ``0``
  116. .. rst-class:: classref-property-setget
  117. - void **set_frame** **(** :ref:`int<class_int>` value **)**
  118. - :ref:`int<class_int>` **get_frame** **(** **)**
  119. 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>`.
  120. .. rst-class:: classref-item-separator
  121. ----
  122. .. _class_AnimatedSprite3D_property_frame_progress:
  123. .. rst-class:: classref-property
  124. :ref:`float<class_float>` **frame_progress** = ``0.0``
  125. .. rst-class:: classref-property-setget
  126. - void **set_frame_progress** **(** :ref:`float<class_float>` value **)**
  127. - :ref:`float<class_float>` **get_frame_progress** **(** **)**
  128. 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``.
  129. .. rst-class:: classref-item-separator
  130. ----
  131. .. _class_AnimatedSprite3D_property_speed_scale:
  132. .. rst-class:: classref-property
  133. :ref:`float<class_float>` **speed_scale** = ``1.0``
  134. .. rst-class:: classref-property-setget
  135. - void **set_speed_scale** **(** :ref:`float<class_float>` value **)**
  136. - :ref:`float<class_float>` **get_speed_scale** **(** **)**
  137. 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.
  138. If set to a negative value, the animation is played in reverse. If set to ``0``, the animation will not advance.
  139. .. rst-class:: classref-item-separator
  140. ----
  141. .. _class_AnimatedSprite3D_property_sprite_frames:
  142. .. rst-class:: classref-property
  143. :ref:`SpriteFrames<class_SpriteFrames>` **sprite_frames**
  144. .. rst-class:: classref-property-setget
  145. - void **set_sprite_frames** **(** :ref:`SpriteFrames<class_SpriteFrames>` value **)**
  146. - :ref:`SpriteFrames<class_SpriteFrames>` **get_sprite_frames** **(** **)**
  147. 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.
  148. .. rst-class:: classref-section-separator
  149. ----
  150. .. rst-class:: classref-descriptions-group
  151. Method Descriptions
  152. -------------------
  153. .. _class_AnimatedSprite3D_method_get_playing_speed:
  154. .. rst-class:: classref-method
  155. :ref:`float<class_float>` **get_playing_speed** **(** **)** |const|
  156. 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.
  157. Returns a negative value if the current animation is playing backwards.
  158. .. rst-class:: classref-item-separator
  159. ----
  160. .. _class_AnimatedSprite3D_method_is_playing:
  161. .. rst-class:: classref-method
  162. :ref:`bool<class_bool>` **is_playing** **(** **)** |const|
  163. Returns ``true`` if an animation is currently playing (even if :ref:`speed_scale<class_AnimatedSprite3D_property_speed_scale>` and/or ``custom_speed`` are ``0``).
  164. .. rst-class:: classref-item-separator
  165. ----
  166. .. _class_AnimatedSprite3D_method_pause:
  167. .. rst-class:: classref-method
  168. void **pause** **(** **)**
  169. 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.
  170. See also :ref:`stop<class_AnimatedSprite3D_method_stop>`.
  171. .. rst-class:: classref-item-separator
  172. ----
  173. .. _class_AnimatedSprite3D_method_play:
  174. .. rst-class:: classref-method
  175. void **play** **(** :ref:`StringName<class_StringName>` name=&"", :ref:`float<class_float>` custom_speed=1.0, :ref:`bool<class_bool>` from_end=false **)**
  176. 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>`).
  177. 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.
  178. .. rst-class:: classref-item-separator
  179. ----
  180. .. _class_AnimatedSprite3D_method_play_backwards:
  181. .. rst-class:: classref-method
  182. void **play_backwards** **(** :ref:`StringName<class_StringName>` name=&"" **)**
  183. Plays the animation with key ``name`` in reverse.
  184. 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.
  185. .. rst-class:: classref-item-separator
  186. ----
  187. .. _class_AnimatedSprite3D_method_set_frame_and_progress:
  188. .. rst-class:: classref-method
  189. void **set_frame_and_progress** **(** :ref:`int<class_int>` frame, :ref:`float<class_float>` progress **)**
  190. The setter of :ref:`frame<class_AnimatedSprite3D_property_frame>` resets the :ref:`frame_progress<class_AnimatedSprite3D_property_frame_progress>` to ``0.0`` implicitly, but this method avoids that.
  191. This is useful when you want to carry over the current :ref:`frame_progress<class_AnimatedSprite3D_property_frame_progress>` to another :ref:`frame<class_AnimatedSprite3D_property_frame>`.
  192. \ **Example:**\
  193. .. tabs::
  194. .. code-tab:: gdscript
  195. # Change the animation with keeping the frame index and progress.
  196. var current_frame = animated_sprite.get_frame()
  197. var current_progress = animated_sprite.get_frame_progress()
  198. animated_sprite.play("walk_another_skin")
  199. animated_sprite.set_frame_and_progress(current_frame, current_progress)
  200. .. rst-class:: classref-item-separator
  201. ----
  202. .. _class_AnimatedSprite3D_method_stop:
  203. .. rst-class:: classref-method
  204. void **stop** **(** **)**
  205. 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>`.
  206. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  207. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  208. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  209. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  210. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  211. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  212. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`