class_spriteframes.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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/SpriteFrames.xml.
  6. .. _class_SpriteFrames:
  7. SpriteFrames
  8. ============
  9. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. Sprite frame library for AnimatedSprite2D and AnimatedSprite3D.
  11. Description
  12. -----------
  13. Sprite frame library for an :ref:`AnimatedSprite2D<class_AnimatedSprite2D>` or :ref:`AnimatedSprite3D<class_AnimatedSprite3D>` node. Contains frames and animation data for playback.
  14. \ **Note:** You can associate a set of normal or specular maps by creating additional ``SpriteFrames`` resources with a ``_normal`` or ``_specular`` suffix. For example, having 3 ``SpriteFrames`` resources ``run``, ``run_normal``, and ``run_specular`` will make it so the ``run`` animation uses normal and specular maps.
  15. Methods
  16. -------
  17. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | void | :ref:`add_animation<class_SpriteFrames_method_add_animation>` **(** :ref:`StringName<class_StringName>` anim **)** |
  19. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | 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 **)** |
  21. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | void | :ref:`clear<class_SpriteFrames_method_clear>` **(** :ref:`StringName<class_StringName>` anim **)** |
  23. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | void | :ref:`clear_all<class_SpriteFrames_method_clear_all>` **(** **)** |
  25. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`bool<class_bool>` | :ref:`get_animation_loop<class_SpriteFrames_method_get_animation_loop>` **(** :ref:`StringName<class_StringName>` anim **)** |const| |
  27. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_animation_names<class_SpriteFrames_method_get_animation_names>` **(** **)** |const| |
  29. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`float<class_float>` | :ref:`get_animation_speed<class_SpriteFrames_method_get_animation_speed>` **(** :ref:`StringName<class_StringName>` anim **)** |const| |
  31. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`Texture2D<class_Texture2D>` | :ref:`get_frame<class_SpriteFrames_method_get_frame>` **(** :ref:`StringName<class_StringName>` anim, :ref:`int<class_int>` idx **)** |const| |
  33. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`int<class_int>` | :ref:`get_frame_count<class_SpriteFrames_method_get_frame_count>` **(** :ref:`StringName<class_StringName>` anim **)** |const| |
  35. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`bool<class_bool>` | :ref:`has_animation<class_SpriteFrames_method_has_animation>` **(** :ref:`StringName<class_StringName>` anim **)** |const| |
  37. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | void | :ref:`remove_animation<class_SpriteFrames_method_remove_animation>` **(** :ref:`StringName<class_StringName>` anim **)** |
  39. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | void | :ref:`remove_frame<class_SpriteFrames_method_remove_frame>` **(** :ref:`StringName<class_StringName>` anim, :ref:`int<class_int>` idx **)** |
  41. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | void | :ref:`rename_animation<class_SpriteFrames_method_rename_animation>` **(** :ref:`StringName<class_StringName>` anim, :ref:`StringName<class_StringName>` newname **)** |
  43. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`set_animation_loop<class_SpriteFrames_method_set_animation_loop>` **(** :ref:`StringName<class_StringName>` anim, :ref:`bool<class_bool>` loop **)** |
  45. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`set_animation_speed<class_SpriteFrames_method_set_animation_speed>` **(** :ref:`StringName<class_StringName>` anim, :ref:`float<class_float>` speed **)** |
  47. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`set_frame<class_SpriteFrames_method_set_frame>` **(** :ref:`StringName<class_StringName>` anim, :ref:`int<class_int>` idx, :ref:`Texture2D<class_Texture2D>` txt **)** |
  49. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. Method Descriptions
  51. -------------------
  52. .. _class_SpriteFrames_method_add_animation:
  53. - void **add_animation** **(** :ref:`StringName<class_StringName>` anim **)**
  54. Adds a new animation to the library.
  55. ----
  56. .. _class_SpriteFrames_method_add_frame:
  57. - void **add_frame** **(** :ref:`StringName<class_StringName>` anim, :ref:`Texture2D<class_Texture2D>` frame, :ref:`int<class_int>` at_position=-1 **)**
  58. Adds a frame to the given animation.
  59. ----
  60. .. _class_SpriteFrames_method_clear:
  61. - void **clear** **(** :ref:`StringName<class_StringName>` anim **)**
  62. Removes all frames from the given animation.
  63. ----
  64. .. _class_SpriteFrames_method_clear_all:
  65. - void **clear_all** **(** **)**
  66. Removes all animations. A "default" animation will be created.
  67. ----
  68. .. _class_SpriteFrames_method_get_animation_loop:
  69. - :ref:`bool<class_bool>` **get_animation_loop** **(** :ref:`StringName<class_StringName>` anim **)** |const|
  70. Returns ``true`` if the given animation is configured to loop when it finishes playing. Otherwise, returns ``false``.
  71. ----
  72. .. _class_SpriteFrames_method_get_animation_names:
  73. - :ref:`PackedStringArray<class_PackedStringArray>` **get_animation_names** **(** **)** |const|
  74. Returns an array containing the names associated to each animation. Values are placed in alphabetical order.
  75. ----
  76. .. _class_SpriteFrames_method_get_animation_speed:
  77. - :ref:`float<class_float>` **get_animation_speed** **(** :ref:`StringName<class_StringName>` anim **)** |const|
  78. The animation's speed in frames per second.
  79. ----
  80. .. _class_SpriteFrames_method_get_frame:
  81. - :ref:`Texture2D<class_Texture2D>` **get_frame** **(** :ref:`StringName<class_StringName>` anim, :ref:`int<class_int>` idx **)** |const|
  82. Returns the animation's selected frame.
  83. ----
  84. .. _class_SpriteFrames_method_get_frame_count:
  85. - :ref:`int<class_int>` **get_frame_count** **(** :ref:`StringName<class_StringName>` anim **)** |const|
  86. Returns the number of frames in the animation.
  87. ----
  88. .. _class_SpriteFrames_method_has_animation:
  89. - :ref:`bool<class_bool>` **has_animation** **(** :ref:`StringName<class_StringName>` anim **)** |const|
  90. If ``true``, the named animation exists.
  91. ----
  92. .. _class_SpriteFrames_method_remove_animation:
  93. - void **remove_animation** **(** :ref:`StringName<class_StringName>` anim **)**
  94. Removes the given animation.
  95. ----
  96. .. _class_SpriteFrames_method_remove_frame:
  97. - void **remove_frame** **(** :ref:`StringName<class_StringName>` anim, :ref:`int<class_int>` idx **)**
  98. Removes the animation's selected frame.
  99. ----
  100. .. _class_SpriteFrames_method_rename_animation:
  101. - void **rename_animation** **(** :ref:`StringName<class_StringName>` anim, :ref:`StringName<class_StringName>` newname **)**
  102. Changes the animation's name to ``newname``.
  103. ----
  104. .. _class_SpriteFrames_method_set_animation_loop:
  105. - void **set_animation_loop** **(** :ref:`StringName<class_StringName>` anim, :ref:`bool<class_bool>` loop **)**
  106. If ``true``, the animation will loop.
  107. ----
  108. .. _class_SpriteFrames_method_set_animation_speed:
  109. - void **set_animation_speed** **(** :ref:`StringName<class_StringName>` anim, :ref:`float<class_float>` speed **)**
  110. The animation's speed in frames per second.
  111. ----
  112. .. _class_SpriteFrames_method_set_frame:
  113. - void **set_frame** **(** :ref:`StringName<class_StringName>` anim, :ref:`int<class_int>` idx, :ref:`Texture2D<class_Texture2D>` txt **)**
  114. Sets the texture of the given frame.
  115. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  116. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  117. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  118. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  119. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  120. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`