class_animatedtexture.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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/AnimatedTexture.xml.
  6. .. _class_AnimatedTexture:
  7. AnimatedTexture
  8. ===============
  9. **Deprecated:** This class does not work properly in current versions and may be removed in the future. There is currently no equivalent workaround.
  10. **Inherits:** :ref:`Texture2D<class_Texture2D>` **<** :ref:`Texture<class_Texture>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  11. Proxy texture for simple frame-based animations.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. **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:`AnimatedSprite2D<class_AnimatedSprite2D>`, it isn't a :ref:`Node<class_Node>`, but has the advantage of being usable anywhere a :ref:`Texture2D<class_Texture2D>` resource can be used, e.g. in a :ref:`TileSet<class_TileSet>`.
  16. The playback of the animation is controlled by the :ref:`speed_scale<class_AnimatedTexture_property_speed_scale>` property, as well as each frame's duration (see :ref:`set_frame_duration<class_AnimatedTexture_method_set_frame_duration>`). The animation loops, i.e. it will restart at frame 0 automatically after playing the last frame.
  17. \ **AnimatedTexture** currently requires all frame textures to have the same size, otherwise the bigger ones will be cropped to match the smallest one.
  18. \ **Note:** AnimatedTexture doesn't support using :ref:`AtlasTexture<class_AtlasTexture>`\ s. Each frame needs to be a separate :ref:`Texture2D<class_Texture2D>`.
  19. \ **Warning:** The current implementation is not efficient for the modern renderers.
  20. .. rst-class:: classref-reftable-group
  21. Properties
  22. ----------
  23. .. table::
  24. :widths: auto
  25. +---------------------------+--------------------------------------------------------------------+----------------------------------------------------------------------------------------+
  26. | :ref:`int<class_int>` | :ref:`current_frame<class_AnimatedTexture_property_current_frame>` | |
  27. +---------------------------+--------------------------------------------------------------------+----------------------------------------------------------------------------------------+
  28. | :ref:`int<class_int>` | :ref:`frames<class_AnimatedTexture_property_frames>` | ``1`` |
  29. +---------------------------+--------------------------------------------------------------------+----------------------------------------------------------------------------------------+
  30. | :ref:`bool<class_bool>` | :ref:`one_shot<class_AnimatedTexture_property_one_shot>` | ``false`` |
  31. +---------------------------+--------------------------------------------------------------------+----------------------------------------------------------------------------------------+
  32. | :ref:`bool<class_bool>` | :ref:`pause<class_AnimatedTexture_property_pause>` | ``false`` |
  33. +---------------------------+--------------------------------------------------------------------+----------------------------------------------------------------------------------------+
  34. | :ref:`bool<class_bool>` | resource_local_to_scene | ``false`` (overrides :ref:`Resource<class_Resource_property_resource_local_to_scene>`) |
  35. +---------------------------+--------------------------------------------------------------------+----------------------------------------------------------------------------------------+
  36. | :ref:`float<class_float>` | :ref:`speed_scale<class_AnimatedTexture_property_speed_scale>` | ``1.0`` |
  37. +---------------------------+--------------------------------------------------------------------+----------------------------------------------------------------------------------------+
  38. .. rst-class:: classref-reftable-group
  39. Methods
  40. -------
  41. .. table::
  42. :widths: auto
  43. +-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`float<class_float>` | :ref:`get_frame_duration<class_AnimatedTexture_method_get_frame_duration>`\ (\ frame\: :ref:`int<class_int>`\ ) |const| |
  45. +-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`Texture2D<class_Texture2D>` | :ref:`get_frame_texture<class_AnimatedTexture_method_get_frame_texture>`\ (\ frame\: :ref:`int<class_int>`\ ) |const| |
  47. +-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | |void| | :ref:`set_frame_duration<class_AnimatedTexture_method_set_frame_duration>`\ (\ frame\: :ref:`int<class_int>`, duration\: :ref:`float<class_float>`\ ) |
  49. +-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | |void| | :ref:`set_frame_texture<class_AnimatedTexture_method_set_frame_texture>`\ (\ frame\: :ref:`int<class_int>`, texture\: :ref:`Texture2D<class_Texture2D>`\ ) |
  51. +-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. .. rst-class:: classref-section-separator
  53. ----
  54. .. rst-class:: classref-descriptions-group
  55. Constants
  56. ---------
  57. .. _class_AnimatedTexture_constant_MAX_FRAMES:
  58. .. rst-class:: classref-constant
  59. **MAX_FRAMES** = ``256`` :ref:`🔗<class_AnimatedTexture_constant_MAX_FRAMES>`
  60. The maximum number of frames supported by **AnimatedTexture**. If you need more frames in your animation, use :ref:`AnimationPlayer<class_AnimationPlayer>` or :ref:`AnimatedSprite2D<class_AnimatedSprite2D>`.
  61. .. rst-class:: classref-section-separator
  62. ----
  63. .. rst-class:: classref-descriptions-group
  64. Property Descriptions
  65. ---------------------
  66. .. _class_AnimatedTexture_property_current_frame:
  67. .. rst-class:: classref-property
  68. :ref:`int<class_int>` **current_frame** :ref:`🔗<class_AnimatedTexture_property_current_frame>`
  69. .. rst-class:: classref-property-setget
  70. - |void| **set_current_frame**\ (\ value\: :ref:`int<class_int>`\ )
  71. - :ref:`int<class_int>` **get_current_frame**\ (\ )
  72. Sets the currently visible frame of the texture. Setting this frame while playing resets the current frame time, so the newly selected frame plays for its whole configured frame duration.
  73. .. rst-class:: classref-item-separator
  74. ----
  75. .. _class_AnimatedTexture_property_frames:
  76. .. rst-class:: classref-property
  77. :ref:`int<class_int>` **frames** = ``1`` :ref:`🔗<class_AnimatedTexture_property_frames>`
  78. .. rst-class:: classref-property-setget
  79. - |void| **set_frames**\ (\ value\: :ref:`int<class_int>`\ )
  80. - :ref:`int<class_int>` **get_frames**\ (\ )
  81. 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>`.
  82. .. rst-class:: classref-item-separator
  83. ----
  84. .. _class_AnimatedTexture_property_one_shot:
  85. .. rst-class:: classref-property
  86. :ref:`bool<class_bool>` **one_shot** = ``false`` :ref:`🔗<class_AnimatedTexture_property_one_shot>`
  87. .. rst-class:: classref-property-setget
  88. - |void| **set_one_shot**\ (\ value\: :ref:`bool<class_bool>`\ )
  89. - :ref:`bool<class_bool>` **get_one_shot**\ (\ )
  90. 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``.
  91. .. rst-class:: classref-item-separator
  92. ----
  93. .. _class_AnimatedTexture_property_pause:
  94. .. rst-class:: classref-property
  95. :ref:`bool<class_bool>` **pause** = ``false`` :ref:`🔗<class_AnimatedTexture_property_pause>`
  96. .. rst-class:: classref-property-setget
  97. - |void| **set_pause**\ (\ value\: :ref:`bool<class_bool>`\ )
  98. - :ref:`bool<class_bool>` **get_pause**\ (\ )
  99. 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``.
  100. .. rst-class:: classref-item-separator
  101. ----
  102. .. _class_AnimatedTexture_property_speed_scale:
  103. .. rst-class:: classref-property
  104. :ref:`float<class_float>` **speed_scale** = ``1.0`` :ref:`🔗<class_AnimatedTexture_property_speed_scale>`
  105. .. rst-class:: classref-property-setget
  106. - |void| **set_speed_scale**\ (\ value\: :ref:`float<class_float>`\ )
  107. - :ref:`float<class_float>` **get_speed_scale**\ (\ )
  108. The animation speed is multiplied by this value. If set to a negative value, the animation is played in reverse.
  109. .. rst-class:: classref-section-separator
  110. ----
  111. .. rst-class:: classref-descriptions-group
  112. Method Descriptions
  113. -------------------
  114. .. _class_AnimatedTexture_method_get_frame_duration:
  115. .. rst-class:: classref-method
  116. :ref:`float<class_float>` **get_frame_duration**\ (\ frame\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_AnimatedTexture_method_get_frame_duration>`
  117. Returns the given ``frame``'s duration, in seconds.
  118. .. rst-class:: classref-item-separator
  119. ----
  120. .. _class_AnimatedTexture_method_get_frame_texture:
  121. .. rst-class:: classref-method
  122. :ref:`Texture2D<class_Texture2D>` **get_frame_texture**\ (\ frame\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_AnimatedTexture_method_get_frame_texture>`
  123. Returns the given frame's :ref:`Texture2D<class_Texture2D>`.
  124. .. rst-class:: classref-item-separator
  125. ----
  126. .. _class_AnimatedTexture_method_set_frame_duration:
  127. .. rst-class:: classref-method
  128. |void| **set_frame_duration**\ (\ frame\: :ref:`int<class_int>`, duration\: :ref:`float<class_float>`\ ) :ref:`🔗<class_AnimatedTexture_method_set_frame_duration>`
  129. Sets the duration of any given ``frame``. The final duration is affected by the :ref:`speed_scale<class_AnimatedTexture_property_speed_scale>`. If set to ``0``, the frame is skipped during playback.
  130. .. rst-class:: classref-item-separator
  131. ----
  132. .. _class_AnimatedTexture_method_set_frame_texture:
  133. .. rst-class:: classref-method
  134. |void| **set_frame_texture**\ (\ frame\: :ref:`int<class_int>`, texture\: :ref:`Texture2D<class_Texture2D>`\ ) :ref:`🔗<class_AnimatedTexture_method_set_frame_texture>`
  135. Assigns a :ref:`Texture2D<class_Texture2D>` 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.
  136. 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.
  137. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  138. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  139. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  140. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  141. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  142. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  143. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  144. .. |void| replace:: :abbr:`void (No return value.)`