class_animatedsprite2d.rst 10 KB

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