class_animatedtexture.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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/AnimatedTexture.xml.
  6. .. _class_AnimatedTexture:
  7. AnimatedTexture
  8. ===============
  9. **Inherits:** :ref:`Texture<class_Texture>` **<** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  10. Proxy texture for simple frame-based animations.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. **AnimatedTexture** is a resource format for frame-based animations, where multiple textures can be chained automatically with a predefined delay for each frame. Unlike :ref:`AnimationPlayer<class_AnimationPlayer>` or :ref:`AnimatedSprite<class_AnimatedSprite>`, it isn't a :ref:`Node<class_Node>`, but has the advantage of being usable anywhere a :ref:`Texture<class_Texture>` resource can be used, e.g. in a :ref:`TileSet<class_TileSet>`.
  15. The playback of the animation is controlled by the :ref:`fps<class_AnimatedTexture_property_fps>` property as well as each frame's optional delay (see :ref:`set_frame_delay<class_AnimatedTexture_method_set_frame_delay>`). The animation loops, i.e. it will restart at frame 0 automatically after playing the last frame.
  16. \ **AnimatedTexture** currently requires all frame textures to have the same size, otherwise the bigger ones will be cropped to match the smallest one.
  17. \ **Note:** AnimatedTexture doesn't support using :ref:`AtlasTexture<class_AtlasTexture>`\ s. Each frame needs to be a separate :ref:`Texture<class_Texture>`.
  18. .. rst-class:: classref-reftable-group
  19. Properties
  20. ----------
  21. .. table::
  22. :widths: auto
  23. +---------------------------+--------------------------------------------------------------------+----------------------------------------------------------------+
  24. | :ref:`int<class_int>` | :ref:`current_frame<class_AnimatedTexture_property_current_frame>` | |
  25. +---------------------------+--------------------------------------------------------------------+----------------------------------------------------------------+
  26. | :ref:`int<class_int>` | flags | ``0`` (overrides :ref:`Texture<class_Texture_property_flags>`) |
  27. +---------------------------+--------------------------------------------------------------------+----------------------------------------------------------------+
  28. | :ref:`float<class_float>` | :ref:`fps<class_AnimatedTexture_property_fps>` | ``4.0`` |
  29. +---------------------------+--------------------------------------------------------------------+----------------------------------------------------------------+
  30. | :ref:`int<class_int>` | :ref:`frames<class_AnimatedTexture_property_frames>` | ``1`` |
  31. +---------------------------+--------------------------------------------------------------------+----------------------------------------------------------------+
  32. | :ref:`bool<class_bool>` | :ref:`oneshot<class_AnimatedTexture_property_oneshot>` | ``false`` |
  33. +---------------------------+--------------------------------------------------------------------+----------------------------------------------------------------+
  34. | :ref:`bool<class_bool>` | :ref:`pause<class_AnimatedTexture_property_pause>` | ``false`` |
  35. +---------------------------+--------------------------------------------------------------------+----------------------------------------------------------------+
  36. .. rst-class:: classref-reftable-group
  37. Methods
  38. -------
  39. .. table::
  40. :widths: auto
  41. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`float<class_float>` | :ref:`get_frame_delay<class_AnimatedTexture_method_get_frame_delay>` **(** :ref:`int<class_int>` frame **)** |const| |
  43. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`Texture<class_Texture>` | :ref:`get_frame_texture<class_AnimatedTexture_method_get_frame_texture>` **(** :ref:`int<class_int>` frame **)** |const| |
  45. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`set_frame_delay<class_AnimatedTexture_method_set_frame_delay>` **(** :ref:`int<class_int>` frame, :ref:`float<class_float>` delay **)** |
  47. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`set_frame_texture<class_AnimatedTexture_method_set_frame_texture>` **(** :ref:`int<class_int>` frame, :ref:`Texture<class_Texture>` texture **)** |
  49. +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. .. rst-class:: classref-section-separator
  51. ----
  52. .. rst-class:: classref-descriptions-group
  53. Constants
  54. ---------
  55. .. _class_AnimatedTexture_constant_MAX_FRAMES:
  56. .. rst-class:: classref-constant
  57. **MAX_FRAMES** = ``256``
  58. The maximum number of frames supported by **AnimatedTexture**. If you need more frames in your animation, use :ref:`AnimationPlayer<class_AnimationPlayer>` or :ref:`AnimatedSprite<class_AnimatedSprite>`.
  59. .. rst-class:: classref-section-separator
  60. ----
  61. .. rst-class:: classref-descriptions-group
  62. Property Descriptions
  63. ---------------------
  64. .. _class_AnimatedTexture_property_current_frame:
  65. .. rst-class:: classref-property
  66. :ref:`int<class_int>` **current_frame**
  67. .. rst-class:: classref-property-setget
  68. - void **set_current_frame** **(** :ref:`int<class_int>` value **)**
  69. - :ref:`int<class_int>` **get_current_frame** **(** **)**
  70. Sets the currently visible frame of the texture.
  71. .. rst-class:: classref-item-separator
  72. ----
  73. .. _class_AnimatedTexture_property_fps:
  74. .. rst-class:: classref-property
  75. :ref:`float<class_float>` **fps** = ``4.0``
  76. .. rst-class:: classref-property-setget
  77. - void **set_fps** **(** :ref:`float<class_float>` value **)**
  78. - :ref:`float<class_float>` **get_fps** **(** **)**
  79. Animation speed in frames per second. This value defines the default time interval between two frames of the animation, and thus the overall duration of the animation loop based on the :ref:`frames<class_AnimatedTexture_property_frames>` property. A value of 0 means no predefined number of frames per second, the animation will play according to each frame's frame delay (see :ref:`set_frame_delay<class_AnimatedTexture_method_set_frame_delay>`).
  80. For example, an animation with 8 frames, no frame delay and a ``fps`` value of 2 will run for 4 seconds, with each frame lasting 0.5 seconds.
  81. .. rst-class:: classref-item-separator
  82. ----
  83. .. _class_AnimatedTexture_property_frames:
  84. .. rst-class:: classref-property
  85. :ref:`int<class_int>` **frames** = ``1``
  86. .. rst-class:: classref-property-setget
  87. - void **set_frames** **(** :ref:`int<class_int>` value **)**
  88. - :ref:`int<class_int>` **get_frames** **(** **)**
  89. Number of frames to use in the animation. While you can create the frames independently with :ref:`set_frame_texture<class_AnimatedTexture_method_set_frame_texture>`, you need to set this value for the animation to take new frames into account. The maximum number of frames is :ref:`MAX_FRAMES<class_AnimatedTexture_constant_MAX_FRAMES>`.
  90. .. rst-class:: classref-item-separator
  91. ----
  92. .. _class_AnimatedTexture_property_oneshot:
  93. .. rst-class:: classref-property
  94. :ref:`bool<class_bool>` **oneshot** = ``false``
  95. .. rst-class:: classref-property-setget
  96. - void **set_oneshot** **(** :ref:`bool<class_bool>` value **)**
  97. - :ref:`bool<class_bool>` **get_oneshot** **(** **)**
  98. If ``true``, the animation will only play once and will not loop back to the first frame after reaching the end. Note that reaching the end will not set :ref:`pause<class_AnimatedTexture_property_pause>` to ``true``.
  99. .. rst-class:: classref-item-separator
  100. ----
  101. .. _class_AnimatedTexture_property_pause:
  102. .. rst-class:: classref-property
  103. :ref:`bool<class_bool>` **pause** = ``false``
  104. .. rst-class:: classref-property-setget
  105. - void **set_pause** **(** :ref:`bool<class_bool>` value **)**
  106. - :ref:`bool<class_bool>` **get_pause** **(** **)**
  107. If ``true``, the animation will pause where it currently is (i.e. at :ref:`current_frame<class_AnimatedTexture_property_current_frame>`). The animation will continue from where it was paused when changing this property to ``false``.
  108. .. rst-class:: classref-section-separator
  109. ----
  110. .. rst-class:: classref-descriptions-group
  111. Method Descriptions
  112. -------------------
  113. .. _class_AnimatedTexture_method_get_frame_delay:
  114. .. rst-class:: classref-method
  115. :ref:`float<class_float>` **get_frame_delay** **(** :ref:`int<class_int>` frame **)** |const|
  116. Returns the given frame's delay value.
  117. .. rst-class:: classref-item-separator
  118. ----
  119. .. _class_AnimatedTexture_method_get_frame_texture:
  120. .. rst-class:: classref-method
  121. :ref:`Texture<class_Texture>` **get_frame_texture** **(** :ref:`int<class_int>` frame **)** |const|
  122. Returns the given frame's :ref:`Texture<class_Texture>`.
  123. .. rst-class:: classref-item-separator
  124. ----
  125. .. _class_AnimatedTexture_method_set_frame_delay:
  126. .. rst-class:: classref-method
  127. void **set_frame_delay** **(** :ref:`int<class_int>` frame, :ref:`float<class_float>` delay **)**
  128. Sets an additional delay (in seconds) between this frame and the next one, that will be added to the time interval defined by :ref:`fps<class_AnimatedTexture_property_fps>`. By default, frames have no delay defined. If a delay value is defined, the final time interval between this frame and the next will be ``1.0 / fps + delay``.
  129. For example, for an animation with 3 frames, 2 FPS and a frame delay on the second frame of 1.2, the resulting playback will be:
  130. ::
  131. Frame 0: 0.5 s (1 / fps)
  132. Frame 1: 1.7 s (1 / fps + 1.2)
  133. Frame 2: 0.5 s (1 / fps)
  134. Total duration: 2.7 s
  135. .. rst-class:: classref-item-separator
  136. ----
  137. .. _class_AnimatedTexture_method_set_frame_texture:
  138. .. rst-class:: classref-method
  139. void **set_frame_texture** **(** :ref:`int<class_int>` frame, :ref:`Texture<class_Texture>` texture **)**
  140. Assigns a :ref:`Texture<class_Texture>` to the given frame. Frame IDs start at 0, so the first frame has ID 0, and the last frame of the animation has ID :ref:`frames<class_AnimatedTexture_property_frames>` - 1.
  141. You can define any number of textures up to :ref:`MAX_FRAMES<class_AnimatedTexture_constant_MAX_FRAMES>`, but keep in mind that only frames from 0 to :ref:`frames<class_AnimatedTexture_property_frames>` - 1 will be part of the animation.
  142. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  143. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  144. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  145. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`