class_animatedsprite2d.rst 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the AnimatedSprite2D.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_AnimatedSprite2D:
  6. AnimatedSprite2D
  7. ================
  8. **Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. Sprite node that can use multiple textures for animation.
  10. Description
  11. -----------
  12. Animations are created using a :ref:`SpriteFrames<class_SpriteFrames>` resource, which can be configured in the editor via the SpriteFrames panel.
  13. **Note:** You can associate a set of normal or specular maps by creating additional :ref:`SpriteFrames<class_SpriteFrames>` resources with a ``_normal`` or ``_specular`` suffix. For example, having 3 :ref:`SpriteFrames<class_SpriteFrames>` resources ``run``, ``run_normal``, and ``run_specular`` will make it so the ``run`` animation uses normal and specular maps.
  14. Tutorials
  15. ---------
  16. - :doc:`../tutorials/2d/2d_sprite_animation`
  17. - `2D Dodge The Creeps Demo <https://godotengine.org/asset-library/asset/515>`__
  18. Properties
  19. ----------
  20. +-----------------------------------------+-----------------------------------------------------------------+-------------------+
  21. | :ref:`StringName<class_StringName>` | :ref:`animation<class_AnimatedSprite2D_property_animation>` | ``&"default"`` |
  22. +-----------------------------------------+-----------------------------------------------------------------+-------------------+
  23. | :ref:`bool<class_bool>` | :ref:`centered<class_AnimatedSprite2D_property_centered>` | ``true`` |
  24. +-----------------------------------------+-----------------------------------------------------------------+-------------------+
  25. | :ref:`bool<class_bool>` | :ref:`flip_h<class_AnimatedSprite2D_property_flip_h>` | ``false`` |
  26. +-----------------------------------------+-----------------------------------------------------------------+-------------------+
  27. | :ref:`bool<class_bool>` | :ref:`flip_v<class_AnimatedSprite2D_property_flip_v>` | ``false`` |
  28. +-----------------------------------------+-----------------------------------------------------------------+-------------------+
  29. | :ref:`int<class_int>` | :ref:`frame<class_AnimatedSprite2D_property_frame>` | ``0`` |
  30. +-----------------------------------------+-----------------------------------------------------------------+-------------------+
  31. | :ref:`SpriteFrames<class_SpriteFrames>` | :ref:`frames<class_AnimatedSprite2D_property_frames>` | |
  32. +-----------------------------------------+-----------------------------------------------------------------+-------------------+
  33. | :ref:`Vector2<class_Vector2>` | :ref:`offset<class_AnimatedSprite2D_property_offset>` | ``Vector2(0, 0)`` |
  34. +-----------------------------------------+-----------------------------------------------------------------+-------------------+
  35. | :ref:`bool<class_bool>` | :ref:`playing<class_AnimatedSprite2D_property_playing>` | ``false`` |
  36. +-----------------------------------------+-----------------------------------------------------------------+-------------------+
  37. | :ref:`float<class_float>` | :ref:`speed_scale<class_AnimatedSprite2D_property_speed_scale>` | ``1.0`` |
  38. +-----------------------------------------+-----------------------------------------------------------------+-------------------+
  39. Methods
  40. -------
  41. +-------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`bool<class_bool>` | :ref:`is_playing<class_AnimatedSprite2D_method_is_playing>` **(** **)** |const| |
  43. +-------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`play<class_AnimatedSprite2D_method_play>` **(** :ref:`StringName<class_StringName>` anim=&"", :ref:`bool<class_bool>` backwards=false **)** |
  45. +-------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`stop<class_AnimatedSprite2D_method_stop>` **(** **)** |
  47. +-------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  48. Signals
  49. -------
  50. .. _class_AnimatedSprite2D_signal_animation_finished:
  51. - **animation_finished** **(** **)**
  52. 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.
  53. ----
  54. .. _class_AnimatedSprite2D_signal_frame_changed:
  55. - **frame_changed** **(** **)**
  56. Emitted when :ref:`frame<class_AnimatedSprite2D_property_frame>` changed.
  57. Property Descriptions
  58. ---------------------
  59. .. _class_AnimatedSprite2D_property_animation:
  60. - :ref:`StringName<class_StringName>` **animation**
  61. +-----------+----------------------+
  62. | *Default* | ``&"default"`` |
  63. +-----------+----------------------+
  64. | *Setter* | set_animation(value) |
  65. +-----------+----------------------+
  66. | *Getter* | get_animation() |
  67. +-----------+----------------------+
  68. The current animation from the ``frames`` resource. If this value changes, the ``frame`` counter is reset.
  69. ----
  70. .. _class_AnimatedSprite2D_property_centered:
  71. - :ref:`bool<class_bool>` **centered**
  72. +-----------+---------------------+
  73. | *Default* | ``true`` |
  74. +-----------+---------------------+
  75. | *Setter* | set_centered(value) |
  76. +-----------+---------------------+
  77. | *Getter* | is_centered() |
  78. +-----------+---------------------+
  79. If ``true``, texture will be centered.
  80. ----
  81. .. _class_AnimatedSprite2D_property_flip_h:
  82. - :ref:`bool<class_bool>` **flip_h**
  83. +-----------+-------------------+
  84. | *Default* | ``false`` |
  85. +-----------+-------------------+
  86. | *Setter* | set_flip_h(value) |
  87. +-----------+-------------------+
  88. | *Getter* | is_flipped_h() |
  89. +-----------+-------------------+
  90. If ``true``, texture is flipped horizontally.
  91. ----
  92. .. _class_AnimatedSprite2D_property_flip_v:
  93. - :ref:`bool<class_bool>` **flip_v**
  94. +-----------+-------------------+
  95. | *Default* | ``false`` |
  96. +-----------+-------------------+
  97. | *Setter* | set_flip_v(value) |
  98. +-----------+-------------------+
  99. | *Getter* | is_flipped_v() |
  100. +-----------+-------------------+
  101. If ``true``, texture is flipped vertically.
  102. ----
  103. .. _class_AnimatedSprite2D_property_frame:
  104. - :ref:`int<class_int>` **frame**
  105. +-----------+------------------+
  106. | *Default* | ``0`` |
  107. +-----------+------------------+
  108. | *Setter* | set_frame(value) |
  109. +-----------+------------------+
  110. | *Getter* | get_frame() |
  111. +-----------+------------------+
  112. The displayed animation frame's index.
  113. ----
  114. .. _class_AnimatedSprite2D_property_frames:
  115. - :ref:`SpriteFrames<class_SpriteFrames>` **frames**
  116. +----------+--------------------------+
  117. | *Setter* | set_sprite_frames(value) |
  118. +----------+--------------------------+
  119. | *Getter* | get_sprite_frames() |
  120. +----------+--------------------------+
  121. The :ref:`SpriteFrames<class_SpriteFrames>` resource containing the animation(s).
  122. ----
  123. .. _class_AnimatedSprite2D_property_offset:
  124. - :ref:`Vector2<class_Vector2>` **offset**
  125. +-----------+-------------------+
  126. | *Default* | ``Vector2(0, 0)`` |
  127. +-----------+-------------------+
  128. | *Setter* | set_offset(value) |
  129. +-----------+-------------------+
  130. | *Getter* | get_offset() |
  131. +-----------+-------------------+
  132. The texture's drawing offset.
  133. ----
  134. .. _class_AnimatedSprite2D_property_playing:
  135. - :ref:`bool<class_bool>` **playing**
  136. +-----------+-----------+
  137. | *Default* | ``false`` |
  138. +-----------+-----------+
  139. If ``true``, the :ref:`animation<class_AnimatedSprite2D_property_animation>` is currently playing.
  140. ----
  141. .. _class_AnimatedSprite2D_property_speed_scale:
  142. - :ref:`float<class_float>` **speed_scale**
  143. +-----------+------------------------+
  144. | *Default* | ``1.0`` |
  145. +-----------+------------------------+
  146. | *Setter* | set_speed_scale(value) |
  147. +-----------+------------------------+
  148. | *Getter* | get_speed_scale() |
  149. +-----------+------------------------+
  150. The animation speed is multiplied by this value.
  151. Method Descriptions
  152. -------------------
  153. .. _class_AnimatedSprite2D_method_is_playing:
  154. - :ref:`bool<class_bool>` **is_playing** **(** **)** |const|
  155. Returns ``true`` if an animation is currently being played.
  156. ----
  157. .. _class_AnimatedSprite2D_method_play:
  158. - void **play** **(** :ref:`StringName<class_StringName>` anim=&"", :ref:`bool<class_bool>` backwards=false **)**
  159. 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.
  160. ----
  161. .. _class_AnimatedSprite2D_method_stop:
  162. - void **stop** **(** **)**
  163. Stops the current animation (does not reset the frame counter).
  164. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  165. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  166. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  167. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  168. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  169. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`