class_spriteframes.rst 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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/SpriteFrames.xml.
  6. .. _class_SpriteFrames:
  7. SpriteFrames
  8. ============
  9. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  10. Sprite frame library for AnimatedSprite and AnimatedSprite3D.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. Sprite frame library for an :ref:`AnimatedSprite<class_AnimatedSprite>` or :ref:`AnimatedSprite3D<class_AnimatedSprite3D>` node. Contains frames and animation data for playback.
  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-reftable-group
  17. Properties
  18. ----------
  19. .. table::
  20. :widths: auto
  21. +---------------------------+---------------------------------------------------+
  22. | :ref:`Array<class_Array>` | :ref:`frames<class_SpriteFrames_property_frames>` |
  23. +---------------------------+---------------------------------------------------+
  24. .. rst-class:: classref-reftable-group
  25. Methods
  26. -------
  27. .. table::
  28. :widths: auto
  29. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | void | :ref:`add_animation<class_SpriteFrames_method_add_animation>` **(** :ref:`String<class_String>` anim **)** |
  31. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | void | :ref:`add_frame<class_SpriteFrames_method_add_frame>` **(** :ref:`String<class_String>` anim, :ref:`Texture<class_Texture>` frame, :ref:`int<class_int>` at_position=-1 **)** |
  33. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`clear<class_SpriteFrames_method_clear>` **(** :ref:`String<class_String>` anim **)** |
  35. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | void | :ref:`clear_all<class_SpriteFrames_method_clear_all>` **(** **)** |
  37. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`bool<class_bool>` | :ref:`get_animation_loop<class_SpriteFrames_method_get_animation_loop>` **(** :ref:`String<class_String>` anim **)** |const| |
  39. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`PoolStringArray<class_PoolStringArray>` | :ref:`get_animation_names<class_SpriteFrames_method_get_animation_names>` **(** **)** |const| |
  41. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`float<class_float>` | :ref:`get_animation_speed<class_SpriteFrames_method_get_animation_speed>` **(** :ref:`String<class_String>` anim **)** |const| |
  43. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`Texture<class_Texture>` | :ref:`get_frame<class_SpriteFrames_method_get_frame>` **(** :ref:`String<class_String>` anim, :ref:`int<class_int>` idx **)** |const| |
  45. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`int<class_int>` | :ref:`get_frame_count<class_SpriteFrames_method_get_frame_count>` **(** :ref:`String<class_String>` anim **)** |const| |
  47. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`bool<class_bool>` | :ref:`has_animation<class_SpriteFrames_method_has_animation>` **(** :ref:`String<class_String>` anim **)** |const| |
  49. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`remove_animation<class_SpriteFrames_method_remove_animation>` **(** :ref:`String<class_String>` anim **)** |
  51. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`remove_frame<class_SpriteFrames_method_remove_frame>` **(** :ref:`String<class_String>` anim, :ref:`int<class_int>` idx **)** |
  53. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`rename_animation<class_SpriteFrames_method_rename_animation>` **(** :ref:`String<class_String>` anim, :ref:`String<class_String>` newname **)** |
  55. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | void | :ref:`set_animation_loop<class_SpriteFrames_method_set_animation_loop>` **(** :ref:`String<class_String>` anim, :ref:`bool<class_bool>` loop **)** |
  57. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | void | :ref:`set_animation_speed<class_SpriteFrames_method_set_animation_speed>` **(** :ref:`String<class_String>` anim, :ref:`float<class_float>` speed **)** |
  59. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | void | :ref:`set_frame<class_SpriteFrames_method_set_frame>` **(** :ref:`String<class_String>` anim, :ref:`int<class_int>` idx, :ref:`Texture<class_Texture>` txt **)** |
  61. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. .. rst-class:: classref-section-separator
  63. ----
  64. .. rst-class:: classref-descriptions-group
  65. Property Descriptions
  66. ---------------------
  67. .. _class_SpriteFrames_property_frames:
  68. .. rst-class:: classref-property
  69. :ref:`Array<class_Array>` **frames**
  70. Compatibility property, always equals to an empty array.
  71. .. rst-class:: classref-section-separator
  72. ----
  73. .. rst-class:: classref-descriptions-group
  74. Method Descriptions
  75. -------------------
  76. .. _class_SpriteFrames_method_add_animation:
  77. .. rst-class:: classref-method
  78. void **add_animation** **(** :ref:`String<class_String>` anim **)**
  79. Adds a new animation to the library.
  80. .. rst-class:: classref-item-separator
  81. ----
  82. .. _class_SpriteFrames_method_add_frame:
  83. .. rst-class:: classref-method
  84. void **add_frame** **(** :ref:`String<class_String>` anim, :ref:`Texture<class_Texture>` frame, :ref:`int<class_int>` at_position=-1 **)**
  85. Adds a frame to the given animation.
  86. .. rst-class:: classref-item-separator
  87. ----
  88. .. _class_SpriteFrames_method_clear:
  89. .. rst-class:: classref-method
  90. void **clear** **(** :ref:`String<class_String>` anim **)**
  91. Removes all frames from the given animation.
  92. .. rst-class:: classref-item-separator
  93. ----
  94. .. _class_SpriteFrames_method_clear_all:
  95. .. rst-class:: classref-method
  96. void **clear_all** **(** **)**
  97. Removes all animations. A "default" animation will be created.
  98. .. rst-class:: classref-item-separator
  99. ----
  100. .. _class_SpriteFrames_method_get_animation_loop:
  101. .. rst-class:: classref-method
  102. :ref:`bool<class_bool>` **get_animation_loop** **(** :ref:`String<class_String>` anim **)** |const|
  103. Returns ``true`` if the given animation is configured to loop when it finishes playing. Otherwise, returns ``false``.
  104. .. rst-class:: classref-item-separator
  105. ----
  106. .. _class_SpriteFrames_method_get_animation_names:
  107. .. rst-class:: classref-method
  108. :ref:`PoolStringArray<class_PoolStringArray>` **get_animation_names** **(** **)** |const|
  109. Returns an array containing the names associated to each animation. Values are placed in alphabetical order.
  110. .. rst-class:: classref-item-separator
  111. ----
  112. .. _class_SpriteFrames_method_get_animation_speed:
  113. .. rst-class:: classref-method
  114. :ref:`float<class_float>` **get_animation_speed** **(** :ref:`String<class_String>` anim **)** |const|
  115. The animation's speed in frames per second.
  116. .. rst-class:: classref-item-separator
  117. ----
  118. .. _class_SpriteFrames_method_get_frame:
  119. .. rst-class:: classref-method
  120. :ref:`Texture<class_Texture>` **get_frame** **(** :ref:`String<class_String>` anim, :ref:`int<class_int>` idx **)** |const|
  121. Returns the animation's selected frame.
  122. .. rst-class:: classref-item-separator
  123. ----
  124. .. _class_SpriteFrames_method_get_frame_count:
  125. .. rst-class:: classref-method
  126. :ref:`int<class_int>` **get_frame_count** **(** :ref:`String<class_String>` anim **)** |const|
  127. Returns the number of frames in the animation.
  128. .. rst-class:: classref-item-separator
  129. ----
  130. .. _class_SpriteFrames_method_has_animation:
  131. .. rst-class:: classref-method
  132. :ref:`bool<class_bool>` **has_animation** **(** :ref:`String<class_String>` anim **)** |const|
  133. If ``true``, the named animation exists.
  134. .. rst-class:: classref-item-separator
  135. ----
  136. .. _class_SpriteFrames_method_remove_animation:
  137. .. rst-class:: classref-method
  138. void **remove_animation** **(** :ref:`String<class_String>` anim **)**
  139. Removes the given animation.
  140. .. rst-class:: classref-item-separator
  141. ----
  142. .. _class_SpriteFrames_method_remove_frame:
  143. .. rst-class:: classref-method
  144. void **remove_frame** **(** :ref:`String<class_String>` anim, :ref:`int<class_int>` idx **)**
  145. Removes the animation's selected frame.
  146. .. rst-class:: classref-item-separator
  147. ----
  148. .. _class_SpriteFrames_method_rename_animation:
  149. .. rst-class:: classref-method
  150. void **rename_animation** **(** :ref:`String<class_String>` anim, :ref:`String<class_String>` newname **)**
  151. Changes the animation's name to ``newname``.
  152. .. rst-class:: classref-item-separator
  153. ----
  154. .. _class_SpriteFrames_method_set_animation_loop:
  155. .. rst-class:: classref-method
  156. void **set_animation_loop** **(** :ref:`String<class_String>` anim, :ref:`bool<class_bool>` loop **)**
  157. If ``true``, the animation will loop.
  158. .. rst-class:: classref-item-separator
  159. ----
  160. .. _class_SpriteFrames_method_set_animation_speed:
  161. .. rst-class:: classref-method
  162. void **set_animation_speed** **(** :ref:`String<class_String>` anim, :ref:`float<class_float>` speed **)**
  163. The animation's speed in frames per second.
  164. .. rst-class:: classref-item-separator
  165. ----
  166. .. _class_SpriteFrames_method_set_frame:
  167. .. rst-class:: classref-method
  168. void **set_frame** **(** :ref:`String<class_String>` anim, :ref:`int<class_int>` idx, :ref:`Texture<class_Texture>` txt **)**
  169. Sets the texture of the given frame.
  170. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  171. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  172. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  173. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`