class_spriteframes.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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 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.
  10. Description
  11. -----------
  12. Sprite frame library for :ref:`AnimatedSprite<class_AnimatedSprite>`. Contains frames and animation data for playback.
  13. Properties
  14. ----------
  15. +---------------------------+---------------------------------------------------+
  16. | :ref:`Array<class_Array>` | :ref:`frames<class_SpriteFrames_property_frames>` |
  17. +---------------------------+---------------------------------------------------+
  18. Methods
  19. -------
  20. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | void | :ref:`add_animation<class_SpriteFrames_method_add_animation>` **(** :ref:`StringName<class_StringName>` anim **)** |
  22. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | void | :ref:`add_frame<class_SpriteFrames_method_add_frame>` **(** :ref:`StringName<class_StringName>` anim, :ref:`Texture2D<class_Texture2D>` frame, :ref:`int<class_int>` at_position=-1 **)** |
  24. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | void | :ref:`clear<class_SpriteFrames_method_clear>` **(** :ref:`StringName<class_StringName>` anim **)** |
  26. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | void | :ref:`clear_all<class_SpriteFrames_method_clear_all>` **(** **)** |
  28. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`bool<class_bool>` | :ref:`get_animation_loop<class_SpriteFrames_method_get_animation_loop>` **(** :ref:`StringName<class_StringName>` anim **)** const |
  30. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_animation_names<class_SpriteFrames_method_get_animation_names>` **(** **)** const |
  32. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`float<class_float>` | :ref:`get_animation_speed<class_SpriteFrames_method_get_animation_speed>` **(** :ref:`StringName<class_StringName>` anim **)** const |
  34. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`Texture2D<class_Texture2D>` | :ref:`get_frame<class_SpriteFrames_method_get_frame>` **(** :ref:`StringName<class_StringName>` anim, :ref:`int<class_int>` idx **)** const |
  36. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`int<class_int>` | :ref:`get_frame_count<class_SpriteFrames_method_get_frame_count>` **(** :ref:`StringName<class_StringName>` anim **)** const |
  38. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`bool<class_bool>` | :ref:`has_animation<class_SpriteFrames_method_has_animation>` **(** :ref:`StringName<class_StringName>` anim **)** const |
  40. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`remove_animation<class_SpriteFrames_method_remove_animation>` **(** :ref:`StringName<class_StringName>` anim **)** |
  42. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | void | :ref:`remove_frame<class_SpriteFrames_method_remove_frame>` **(** :ref:`StringName<class_StringName>` anim, :ref:`int<class_int>` idx **)** |
  44. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | void | :ref:`rename_animation<class_SpriteFrames_method_rename_animation>` **(** :ref:`StringName<class_StringName>` anim, :ref:`StringName<class_StringName>` newname **)** |
  46. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | void | :ref:`set_animation_loop<class_SpriteFrames_method_set_animation_loop>` **(** :ref:`StringName<class_StringName>` anim, :ref:`bool<class_bool>` loop **)** |
  48. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | void | :ref:`set_animation_speed<class_SpriteFrames_method_set_animation_speed>` **(** :ref:`StringName<class_StringName>` anim, :ref:`float<class_float>` speed **)** |
  50. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | void | :ref:`set_frame<class_SpriteFrames_method_set_frame>` **(** :ref:`StringName<class_StringName>` anim, :ref:`int<class_int>` idx, :ref:`Texture2D<class_Texture2D>` txt **)** |
  52. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. Property Descriptions
  54. ---------------------
  55. .. _class_SpriteFrames_property_frames:
  56. - :ref:`Array<class_Array>` **frames**
  57. Compatibility property, always equals to an empty array.
  58. Method Descriptions
  59. -------------------
  60. .. _class_SpriteFrames_method_add_animation:
  61. - void **add_animation** **(** :ref:`StringName<class_StringName>` anim **)**
  62. Adds a new animation to the library.
  63. ----
  64. .. _class_SpriteFrames_method_add_frame:
  65. - void **add_frame** **(** :ref:`StringName<class_StringName>` anim, :ref:`Texture2D<class_Texture2D>` frame, :ref:`int<class_int>` at_position=-1 **)**
  66. Adds a frame to the given animation.
  67. ----
  68. .. _class_SpriteFrames_method_clear:
  69. - void **clear** **(** :ref:`StringName<class_StringName>` anim **)**
  70. Removes all frames from the given animation.
  71. ----
  72. .. _class_SpriteFrames_method_clear_all:
  73. - void **clear_all** **(** **)**
  74. Removes all animations. A "default" animation will be created.
  75. ----
  76. .. _class_SpriteFrames_method_get_animation_loop:
  77. - :ref:`bool<class_bool>` **get_animation_loop** **(** :ref:`StringName<class_StringName>` anim **)** const
  78. If ``true``, the given animation will loop.
  79. ----
  80. .. _class_SpriteFrames_method_get_animation_names:
  81. - :ref:`PackedStringArray<class_PackedStringArray>` **get_animation_names** **(** **)** const
  82. Returns an array containing the names associated to each animation. Values are placed in alphabetical order.
  83. ----
  84. .. _class_SpriteFrames_method_get_animation_speed:
  85. - :ref:`float<class_float>` **get_animation_speed** **(** :ref:`StringName<class_StringName>` anim **)** const
  86. The animation's speed in frames per second.
  87. ----
  88. .. _class_SpriteFrames_method_get_frame:
  89. - :ref:`Texture2D<class_Texture2D>` **get_frame** **(** :ref:`StringName<class_StringName>` anim, :ref:`int<class_int>` idx **)** const
  90. Returns the animation's selected frame.
  91. ----
  92. .. _class_SpriteFrames_method_get_frame_count:
  93. - :ref:`int<class_int>` **get_frame_count** **(** :ref:`StringName<class_StringName>` anim **)** const
  94. Returns the number of frames in the animation.
  95. ----
  96. .. _class_SpriteFrames_method_has_animation:
  97. - :ref:`bool<class_bool>` **has_animation** **(** :ref:`StringName<class_StringName>` anim **)** const
  98. If ``true``, the named animation exists.
  99. ----
  100. .. _class_SpriteFrames_method_remove_animation:
  101. - void **remove_animation** **(** :ref:`StringName<class_StringName>` anim **)**
  102. Removes the given animation.
  103. ----
  104. .. _class_SpriteFrames_method_remove_frame:
  105. - void **remove_frame** **(** :ref:`StringName<class_StringName>` anim, :ref:`int<class_int>` idx **)**
  106. Removes the animation's selected frame.
  107. ----
  108. .. _class_SpriteFrames_method_rename_animation:
  109. - void **rename_animation** **(** :ref:`StringName<class_StringName>` anim, :ref:`StringName<class_StringName>` newname **)**
  110. Changes the animation's name to ``newname``.
  111. ----
  112. .. _class_SpriteFrames_method_set_animation_loop:
  113. - void **set_animation_loop** **(** :ref:`StringName<class_StringName>` anim, :ref:`bool<class_bool>` loop **)**
  114. If ``true``, the animation will loop.
  115. ----
  116. .. _class_SpriteFrames_method_set_animation_speed:
  117. - void **set_animation_speed** **(** :ref:`StringName<class_StringName>` anim, :ref:`float<class_float>` speed **)**
  118. The animation's speed in frames per second.
  119. ----
  120. .. _class_SpriteFrames_method_set_frame:
  121. - void **set_frame** **(** :ref:`StringName<class_StringName>` anim, :ref:`int<class_int>` idx, :ref:`Texture2D<class_Texture2D>` txt **)**
  122. Sets the texture of the given frame.