class_animatedsprite.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/AnimatedSprite.xml.
  6. .. _class_AnimatedSprite:
  7. AnimatedSprite
  8. ==============
  9. **Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. Sprite node that contains multiple textures as frames to play for animation.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. **AnimatedSprite** is similar to the :ref:`Sprite<class_Sprite>` node, except it carries multiple textures as animation 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. \ **Note:** You can associate a set of normal maps by creating additional animations with a ``_normal`` suffix. For example, having 2 animations ``run`` and ``run_normal`` will make it so the ``run`` animation uses the normal map.
  16. .. rst-class:: classref-introduction-group
  17. Tutorials
  18. ---------
  19. - :doc:`2D Sprite animation <../tutorials/2d/2d_sprite_animation>`
  20. - `2D Dodge The Creeps Demo <https://godotengine.org/asset-library/asset/515>`__
  21. .. rst-class:: classref-reftable-group
  22. Properties
  23. ----------
  24. .. table::
  25. :widths: auto
  26. +-----------------------------------------+---------------------------------------------------------------+---------------------+
  27. | :ref:`String<class_String>` | :ref:`animation<class_AnimatedSprite_property_animation>` | ``"default"`` |
  28. +-----------------------------------------+---------------------------------------------------------------+---------------------+
  29. | :ref:`bool<class_bool>` | :ref:`centered<class_AnimatedSprite_property_centered>` | ``true`` |
  30. +-----------------------------------------+---------------------------------------------------------------+---------------------+
  31. | :ref:`bool<class_bool>` | :ref:`flip_h<class_AnimatedSprite_property_flip_h>` | ``false`` |
  32. +-----------------------------------------+---------------------------------------------------------------+---------------------+
  33. | :ref:`bool<class_bool>` | :ref:`flip_v<class_AnimatedSprite_property_flip_v>` | ``false`` |
  34. +-----------------------------------------+---------------------------------------------------------------+---------------------+
  35. | :ref:`int<class_int>` | :ref:`frame<class_AnimatedSprite_property_frame>` | ``0`` |
  36. +-----------------------------------------+---------------------------------------------------------------+---------------------+
  37. | :ref:`SpriteFrames<class_SpriteFrames>` | :ref:`frames<class_AnimatedSprite_property_frames>` | |
  38. +-----------------------------------------+---------------------------------------------------------------+---------------------+
  39. | :ref:`Vector2<class_Vector2>` | :ref:`offset<class_AnimatedSprite_property_offset>` | ``Vector2( 0, 0 )`` |
  40. +-----------------------------------------+---------------------------------------------------------------+---------------------+
  41. | :ref:`bool<class_bool>` | :ref:`playing<class_AnimatedSprite_property_playing>` | ``false`` |
  42. +-----------------------------------------+---------------------------------------------------------------+---------------------+
  43. | :ref:`float<class_float>` | :ref:`speed_scale<class_AnimatedSprite_property_speed_scale>` | ``1.0`` |
  44. +-----------------------------------------+---------------------------------------------------------------+---------------------+
  45. .. rst-class:: classref-reftable-group
  46. Methods
  47. -------
  48. .. table::
  49. :widths: auto
  50. +------+----------------------------------------------------------------------------------------------------------------------------------------+
  51. | void | :ref:`play<class_AnimatedSprite_method_play>` **(** :ref:`String<class_String>` anim="", :ref:`bool<class_bool>` backwards=false **)** |
  52. +------+----------------------------------------------------------------------------------------------------------------------------------------+
  53. | void | :ref:`stop<class_AnimatedSprite_method_stop>` **(** **)** |
  54. +------+----------------------------------------------------------------------------------------------------------------------------------------+
  55. .. rst-class:: classref-section-separator
  56. ----
  57. .. rst-class:: classref-descriptions-group
  58. Signals
  59. -------
  60. .. _class_AnimatedSprite_signal_animation_finished:
  61. .. rst-class:: classref-signal
  62. **animation_finished** **(** **)**
  63. Emitted when the animation is finished (when it plays the last frame). If the animation is looping, this signal is emitted every time the last frame is drawn.
  64. .. rst-class:: classref-item-separator
  65. ----
  66. .. _class_AnimatedSprite_signal_frame_changed:
  67. .. rst-class:: classref-signal
  68. **frame_changed** **(** **)**
  69. Emitted when :ref:`frame<class_AnimatedSprite_property_frame>` changed.
  70. .. rst-class:: classref-section-separator
  71. ----
  72. .. rst-class:: classref-descriptions-group
  73. Property Descriptions
  74. ---------------------
  75. .. _class_AnimatedSprite_property_animation:
  76. .. rst-class:: classref-property
  77. :ref:`String<class_String>` **animation** = ``"default"``
  78. .. rst-class:: classref-property-setget
  79. - void **set_animation** **(** :ref:`String<class_String>` value **)**
  80. - :ref:`String<class_String>` **get_animation** **(** **)**
  81. The current animation from the :ref:`frames<class_AnimatedSprite_property_frames>` resource. If this value changes, the ``frame`` counter is reset.
  82. .. rst-class:: classref-item-separator
  83. ----
  84. .. _class_AnimatedSprite_property_centered:
  85. .. rst-class:: classref-property
  86. :ref:`bool<class_bool>` **centered** = ``true``
  87. .. rst-class:: classref-property-setget
  88. - void **set_centered** **(** :ref:`bool<class_bool>` value **)**
  89. - :ref:`bool<class_bool>` **is_centered** **(** **)**
  90. If ``true``, texture will be centered.
  91. .. rst-class:: classref-item-separator
  92. ----
  93. .. _class_AnimatedSprite_property_flip_h:
  94. .. rst-class:: classref-property
  95. :ref:`bool<class_bool>` **flip_h** = ``false``
  96. .. rst-class:: classref-property-setget
  97. - void **set_flip_h** **(** :ref:`bool<class_bool>` value **)**
  98. - :ref:`bool<class_bool>` **is_flipped_h** **(** **)**
  99. If ``true``, texture is flipped horizontally.
  100. .. rst-class:: classref-item-separator
  101. ----
  102. .. _class_AnimatedSprite_property_flip_v:
  103. .. rst-class:: classref-property
  104. :ref:`bool<class_bool>` **flip_v** = ``false``
  105. .. rst-class:: classref-property-setget
  106. - void **set_flip_v** **(** :ref:`bool<class_bool>` value **)**
  107. - :ref:`bool<class_bool>` **is_flipped_v** **(** **)**
  108. If ``true``, texture is flipped vertically.
  109. .. rst-class:: classref-item-separator
  110. ----
  111. .. _class_AnimatedSprite_property_frame:
  112. .. rst-class:: classref-property
  113. :ref:`int<class_int>` **frame** = ``0``
  114. .. rst-class:: classref-property-setget
  115. - void **set_frame** **(** :ref:`int<class_int>` value **)**
  116. - :ref:`int<class_int>` **get_frame** **(** **)**
  117. The displayed animation frame's index.
  118. .. rst-class:: classref-item-separator
  119. ----
  120. .. _class_AnimatedSprite_property_frames:
  121. .. rst-class:: classref-property
  122. :ref:`SpriteFrames<class_SpriteFrames>` **frames**
  123. .. rst-class:: classref-property-setget
  124. - void **set_sprite_frames** **(** :ref:`SpriteFrames<class_SpriteFrames>` value **)**
  125. - :ref:`SpriteFrames<class_SpriteFrames>` **get_sprite_frames** **(** **)**
  126. 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.
  127. .. rst-class:: classref-item-separator
  128. ----
  129. .. _class_AnimatedSprite_property_offset:
  130. .. rst-class:: classref-property
  131. :ref:`Vector2<class_Vector2>` **offset** = ``Vector2( 0, 0 )``
  132. .. rst-class:: classref-property-setget
  133. - void **set_offset** **(** :ref:`Vector2<class_Vector2>` value **)**
  134. - :ref:`Vector2<class_Vector2>` **get_offset** **(** **)**
  135. The texture's drawing offset.
  136. .. rst-class:: classref-item-separator
  137. ----
  138. .. _class_AnimatedSprite_property_playing:
  139. .. rst-class:: classref-property
  140. :ref:`bool<class_bool>` **playing** = ``false``
  141. .. rst-class:: classref-property-setget
  142. - void **set_playing** **(** :ref:`bool<class_bool>` value **)**
  143. - :ref:`bool<class_bool>` **is_playing** **(** **)**
  144. If ``true``, the :ref:`animation<class_AnimatedSprite_property_animation>` is currently playing.
  145. .. rst-class:: classref-item-separator
  146. ----
  147. .. _class_AnimatedSprite_property_speed_scale:
  148. .. rst-class:: classref-property
  149. :ref:`float<class_float>` **speed_scale** = ``1.0``
  150. .. rst-class:: classref-property-setget
  151. - void **set_speed_scale** **(** :ref:`float<class_float>` value **)**
  152. - :ref:`float<class_float>` **get_speed_scale** **(** **)**
  153. The animation speed is multiplied by this value.
  154. .. rst-class:: classref-section-separator
  155. ----
  156. .. rst-class:: classref-descriptions-group
  157. Method Descriptions
  158. -------------------
  159. .. _class_AnimatedSprite_method_play:
  160. .. rst-class:: classref-method
  161. void **play** **(** :ref:`String<class_String>` anim="", :ref:`bool<class_bool>` backwards=false **)**
  162. Plays the animation named ``anim``. If no ``anim`` is provided, the current animation is played. If ``backwards`` is ``true``, the animation will be played in reverse.
  163. .. rst-class:: classref-item-separator
  164. ----
  165. .. _class_AnimatedSprite_method_stop:
  166. .. rst-class:: classref-method
  167. void **stop** **(** **)**
  168. Stops the current animation (does not reset the frame counter).
  169. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  170. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  171. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  172. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`