class_spriteframes.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the SpriteFrames.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_SpriteFrames:
  6. SpriteFrames
  7. ============
  8. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  9. Sprite frame library for AnimatedSprite and AnimatedSprite3D.
  10. Description
  11. -----------
  12. Sprite frame library for an :ref:`AnimatedSprite<class_AnimatedSprite>` or :ref:`AnimatedSprite3D<class_AnimatedSprite3D>` node. Contains frames and animation data for playback.
  13. **Note:** You can associate a set of normal maps by creating additional ``SpriteFrames`` resources with a ``_normal`` suffix. For example, having 2 ``SpriteFrames`` resources ``run`` and ``run_normal`` will make it so the ``run`` animation uses the normal map.
  14. Properties
  15. ----------
  16. +---------------------------+---------------------------------------------------+
  17. | :ref:`Array<class_Array>` | :ref:`frames<class_SpriteFrames_property_frames>` |
  18. +---------------------------+---------------------------------------------------+
  19. Methods
  20. -------
  21. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | void | :ref:`add_animation<class_SpriteFrames_method_add_animation>` **(** :ref:`String<class_String>` anim **)** |
  23. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | 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 **)** |
  25. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | void | :ref:`clear<class_SpriteFrames_method_clear>` **(** :ref:`String<class_String>` anim **)** |
  27. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | void | :ref:`clear_all<class_SpriteFrames_method_clear_all>` **(** **)** |
  29. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`bool<class_bool>` | :ref:`get_animation_loop<class_SpriteFrames_method_get_animation_loop>` **(** :ref:`String<class_String>` anim **)** |const| |
  31. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`PoolStringArray<class_PoolStringArray>` | :ref:`get_animation_names<class_SpriteFrames_method_get_animation_names>` **(** **)** |const| |
  33. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`float<class_float>` | :ref:`get_animation_speed<class_SpriteFrames_method_get_animation_speed>` **(** :ref:`String<class_String>` anim **)** |const| |
  35. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`Texture<class_Texture>` | :ref:`get_frame<class_SpriteFrames_method_get_frame>` **(** :ref:`String<class_String>` anim, :ref:`int<class_int>` idx **)** |const| |
  37. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`int<class_int>` | :ref:`get_frame_count<class_SpriteFrames_method_get_frame_count>` **(** :ref:`String<class_String>` anim **)** |const| |
  39. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`bool<class_bool>` | :ref:`has_animation<class_SpriteFrames_method_has_animation>` **(** :ref:`String<class_String>` anim **)** |const| |
  41. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | void | :ref:`remove_animation<class_SpriteFrames_method_remove_animation>` **(** :ref:`String<class_String>` anim **)** |
  43. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`remove_frame<class_SpriteFrames_method_remove_frame>` **(** :ref:`String<class_String>` anim, :ref:`int<class_int>` idx **)** |
  45. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`rename_animation<class_SpriteFrames_method_rename_animation>` **(** :ref:`String<class_String>` anim, :ref:`String<class_String>` newname **)** |
  47. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`set_animation_loop<class_SpriteFrames_method_set_animation_loop>` **(** :ref:`String<class_String>` anim, :ref:`bool<class_bool>` loop **)** |
  49. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`set_animation_speed<class_SpriteFrames_method_set_animation_speed>` **(** :ref:`String<class_String>` anim, :ref:`float<class_float>` speed **)** |
  51. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`set_frame<class_SpriteFrames_method_set_frame>` **(** :ref:`String<class_String>` anim, :ref:`int<class_int>` idx, :ref:`Texture<class_Texture>` txt **)** |
  53. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. Property Descriptions
  55. ---------------------
  56. .. _class_SpriteFrames_property_frames:
  57. - :ref:`Array<class_Array>` **frames**
  58. Compatibility property, always equals to an empty array.
  59. Method Descriptions
  60. -------------------
  61. .. _class_SpriteFrames_method_add_animation:
  62. - void **add_animation** **(** :ref:`String<class_String>` anim **)**
  63. Adds a new animation to the library.
  64. ----
  65. .. _class_SpriteFrames_method_add_frame:
  66. - void **add_frame** **(** :ref:`String<class_String>` anim, :ref:`Texture<class_Texture>` frame, :ref:`int<class_int>` at_position=-1 **)**
  67. Adds a frame to the given animation.
  68. ----
  69. .. _class_SpriteFrames_method_clear:
  70. - void **clear** **(** :ref:`String<class_String>` anim **)**
  71. Removes all frames from the given animation.
  72. ----
  73. .. _class_SpriteFrames_method_clear_all:
  74. - void **clear_all** **(** **)**
  75. Removes all animations. A "default" animation will be created.
  76. ----
  77. .. _class_SpriteFrames_method_get_animation_loop:
  78. - :ref:`bool<class_bool>` **get_animation_loop** **(** :ref:`String<class_String>` anim **)** |const|
  79. Returns ``true`` if the given animation is configured to loop when it finishes playing. Otherwise, returns ``false``.
  80. ----
  81. .. _class_SpriteFrames_method_get_animation_names:
  82. - :ref:`PoolStringArray<class_PoolStringArray>` **get_animation_names** **(** **)** |const|
  83. Returns an array containing the names associated to each animation. Values are placed in alphabetical order.
  84. ----
  85. .. _class_SpriteFrames_method_get_animation_speed:
  86. - :ref:`float<class_float>` **get_animation_speed** **(** :ref:`String<class_String>` anim **)** |const|
  87. The animation's speed in frames per second.
  88. ----
  89. .. _class_SpriteFrames_method_get_frame:
  90. - :ref:`Texture<class_Texture>` **get_frame** **(** :ref:`String<class_String>` anim, :ref:`int<class_int>` idx **)** |const|
  91. Returns the animation's selected frame.
  92. ----
  93. .. _class_SpriteFrames_method_get_frame_count:
  94. - :ref:`int<class_int>` **get_frame_count** **(** :ref:`String<class_String>` anim **)** |const|
  95. Returns the number of frames in the animation.
  96. ----
  97. .. _class_SpriteFrames_method_has_animation:
  98. - :ref:`bool<class_bool>` **has_animation** **(** :ref:`String<class_String>` anim **)** |const|
  99. If ``true``, the named animation exists.
  100. ----
  101. .. _class_SpriteFrames_method_remove_animation:
  102. - void **remove_animation** **(** :ref:`String<class_String>` anim **)**
  103. Removes the given animation.
  104. ----
  105. .. _class_SpriteFrames_method_remove_frame:
  106. - void **remove_frame** **(** :ref:`String<class_String>` anim, :ref:`int<class_int>` idx **)**
  107. Removes the animation's selected frame.
  108. ----
  109. .. _class_SpriteFrames_method_rename_animation:
  110. - void **rename_animation** **(** :ref:`String<class_String>` anim, :ref:`String<class_String>` newname **)**
  111. Changes the animation's name to ``newname``.
  112. ----
  113. .. _class_SpriteFrames_method_set_animation_loop:
  114. - void **set_animation_loop** **(** :ref:`String<class_String>` anim, :ref:`bool<class_bool>` loop **)**
  115. If ``true``, the animation will loop.
  116. ----
  117. .. _class_SpriteFrames_method_set_animation_speed:
  118. - void **set_animation_speed** **(** :ref:`String<class_String>` anim, :ref:`float<class_float>` speed **)**
  119. The animation's speed in frames per second.
  120. ----
  121. .. _class_SpriteFrames_method_set_frame:
  122. - void **set_frame** **(** :ref:`String<class_String>` anim, :ref:`int<class_int>` idx, :ref:`Texture<class_Texture>` txt **)**
  123. Sets the texture of the given frame.
  124. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  125. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  126. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`