class_animatedsprite3d.rst 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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:`frames<class_AnimatedSprite3D_property_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. After setting up :ref:`frames<class_AnimatedSprite3D_property_frames>`, :ref:`play<class_AnimatedSprite3D_method_play>` may be called. It's also possible to select an :ref:`animation<class_AnimatedSprite3D_property_animation>` and toggle :ref:`playing<class_AnimatedSprite3D_property_playing>`, even within the editor.
  16. To pause the current animation, set :ref:`playing<class_AnimatedSprite3D_property_playing>` to ``false``. Alternatively, setting :ref:`speed_scale<class_AnimatedSprite3D_property_speed_scale>` to ``0`` also preserves the current frame's elapsed time.
  17. .. rst-class:: classref-introduction-group
  18. Tutorials
  19. ---------
  20. - :doc:`2D Sprite animation (also applies to 3D) <../tutorials/2d/2d_sprite_animation>`
  21. .. rst-class:: classref-reftable-group
  22. Properties
  23. ----------
  24. .. table::
  25. :widths: auto
  26. +-----------------------------------------+-----------------------------------------------------------------+----------------+
  27. | :ref:`StringName<class_StringName>` | :ref:`animation<class_AnimatedSprite3D_property_animation>` | ``&"default"`` |
  28. +-----------------------------------------+-----------------------------------------------------------------+----------------+
  29. | :ref:`int<class_int>` | :ref:`frame<class_AnimatedSprite3D_property_frame>` | ``0`` |
  30. +-----------------------------------------+-----------------------------------------------------------------+----------------+
  31. | :ref:`SpriteFrames<class_SpriteFrames>` | :ref:`frames<class_AnimatedSprite3D_property_frames>` | |
  32. +-----------------------------------------+-----------------------------------------------------------------+----------------+
  33. | :ref:`bool<class_bool>` | :ref:`playing<class_AnimatedSprite3D_property_playing>` | ``false`` |
  34. +-----------------------------------------+-----------------------------------------------------------------+----------------+
  35. | :ref:`float<class_float>` | :ref:`speed_scale<class_AnimatedSprite3D_property_speed_scale>` | ``1.0`` |
  36. +-----------------------------------------+-----------------------------------------------------------------+----------------+
  37. .. rst-class:: classref-reftable-group
  38. Methods
  39. -------
  40. .. table::
  41. :widths: auto
  42. +------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | void | :ref:`play<class_AnimatedSprite3D_method_play>` **(** :ref:`StringName<class_StringName>` anim=&"", :ref:`bool<class_bool>` backwards=false **)** |
  44. +------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | void | :ref:`stop<class_AnimatedSprite3D_method_stop>` **(** **)** |
  46. +------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  47. .. rst-class:: classref-section-separator
  48. ----
  49. .. rst-class:: classref-descriptions-group
  50. Signals
  51. -------
  52. .. _class_AnimatedSprite3D_signal_animation_finished:
  53. .. rst-class:: classref-signal
  54. **animation_finished** **(** **)**
  55. Emitted when the animation reaches the end, or the start if it is played in reverse. If the animation is looping, this signal is emitted at the end of each loop.
  56. .. rst-class:: classref-item-separator
  57. ----
  58. .. _class_AnimatedSprite3D_signal_frame_changed:
  59. .. rst-class:: classref-signal
  60. **frame_changed** **(** **)**
  61. Emitted when :ref:`frame<class_AnimatedSprite3D_property_frame>` changed.
  62. .. rst-class:: classref-section-separator
  63. ----
  64. .. rst-class:: classref-descriptions-group
  65. Property Descriptions
  66. ---------------------
  67. .. _class_AnimatedSprite3D_property_animation:
  68. .. rst-class:: classref-property
  69. :ref:`StringName<class_StringName>` **animation** = ``&"default"``
  70. .. rst-class:: classref-property-setget
  71. - void **set_animation** **(** :ref:`StringName<class_StringName>` value **)**
  72. - :ref:`StringName<class_StringName>` **get_animation** **(** **)**
  73. The current animation from the ``frames`` resource. If this value changes, the ``frame`` counter is reset.
  74. .. rst-class:: classref-item-separator
  75. ----
  76. .. _class_AnimatedSprite3D_property_frame:
  77. .. rst-class:: classref-property
  78. :ref:`int<class_int>` **frame** = ``0``
  79. .. rst-class:: classref-property-setget
  80. - void **set_frame** **(** :ref:`int<class_int>` value **)**
  81. - :ref:`int<class_int>` **get_frame** **(** **)**
  82. The displayed animation frame's index.
  83. .. rst-class:: classref-item-separator
  84. ----
  85. .. _class_AnimatedSprite3D_property_frames:
  86. .. rst-class:: classref-property
  87. :ref:`SpriteFrames<class_SpriteFrames>` **frames**
  88. .. rst-class:: classref-property-setget
  89. - void **set_sprite_frames** **(** :ref:`SpriteFrames<class_SpriteFrames>` value **)**
  90. - :ref:`SpriteFrames<class_SpriteFrames>` **get_sprite_frames** **(** **)**
  91. The :ref:`SpriteFrames<class_SpriteFrames>` resource containing the animation(s).
  92. .. rst-class:: classref-item-separator
  93. ----
  94. .. _class_AnimatedSprite3D_property_playing:
  95. .. rst-class:: classref-property
  96. :ref:`bool<class_bool>` **playing** = ``false``
  97. .. rst-class:: classref-property-setget
  98. - void **set_playing** **(** :ref:`bool<class_bool>` value **)**
  99. - :ref:`bool<class_bool>` **is_playing** **(** **)**
  100. If ``true``, the :ref:`animation<class_AnimatedSprite3D_property_animation>` is currently playing. Setting this property to ``false`` pauses the current animation. Use :ref:`stop<class_AnimatedSprite3D_method_stop>` to stop the animation at the current frame instead.
  101. \ **Note:** Unlike :ref:`stop<class_AnimatedSprite3D_method_stop>`, changing this property to ``false`` preserves the current frame's elapsed time and the ``backwards`` flag of the current :ref:`animation<class_AnimatedSprite3D_property_animation>` (if it was previously set by :ref:`play<class_AnimatedSprite3D_method_play>`).
  102. \ **Note:** After a non-looping animation finishes, the property still remains ``true``.
  103. .. rst-class:: classref-item-separator
  104. ----
  105. .. _class_AnimatedSprite3D_property_speed_scale:
  106. .. rst-class:: classref-property
  107. :ref:`float<class_float>` **speed_scale** = ``1.0``
  108. .. rst-class:: classref-property-setget
  109. - void **set_speed_scale** **(** :ref:`float<class_float>` value **)**
  110. - :ref:`float<class_float>` **get_speed_scale** **(** **)**
  111. The animation speed is multiplied by this value. If set to a negative value, the animation is played in reverse. If set to ``0``, the animation is paused, preserving the current frame's elapsed time.
  112. .. rst-class:: classref-section-separator
  113. ----
  114. .. rst-class:: classref-descriptions-group
  115. Method Descriptions
  116. -------------------
  117. .. _class_AnimatedSprite3D_method_play:
  118. .. rst-class:: classref-method
  119. void **play** **(** :ref:`StringName<class_StringName>` anim=&"", :ref:`bool<class_bool>` backwards=false **)**
  120. Plays the animation named ``anim``. If no ``anim`` is provided, the current animation is played. If ``backwards`` is ``true``, the animation is played in reverse.
  121. \ **Note:** If :ref:`speed_scale<class_AnimatedSprite3D_property_speed_scale>` is negative, the animation direction specified by ``backwards`` will be inverted.
  122. .. rst-class:: classref-item-separator
  123. ----
  124. .. _class_AnimatedSprite3D_method_stop:
  125. .. rst-class:: classref-method
  126. void **stop** **(** **)**
  127. Stops the current :ref:`animation<class_AnimatedSprite3D_property_animation>` at the current :ref:`frame<class_AnimatedSprite3D_property_frame>`.
  128. \ **Note:** This method resets the current frame's elapsed time and removes the ``backwards`` flag from the current :ref:`animation<class_AnimatedSprite3D_property_animation>` (if it was previously set by :ref:`play<class_AnimatedSprite3D_method_play>`). If this behavior is undesired, set :ref:`playing<class_AnimatedSprite3D_property_playing>` to ``false`` instead.
  129. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  130. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  131. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  132. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  133. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  134. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`