AnimatedTexture.xml 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="AnimatedTexture" inherits="Texture" category="Core" version="3.1">
  3. <brief_description>
  4. Proxy texture for simple frame-based animations.
  5. </brief_description>
  6. <description>
  7. [code]AnimatedTexture[/code] is a resource format for simple frame-based animations, where multiple frames textures can be chained automatically with a predefined delay for each frame. It's not a [Node], contrarily to [AnimationPlayer] or [AnimatedSprite], but has the advantage of being usable at any place where a [Texture] resource can be used, e.g. in a [TileSet].
  8. The playback of the animation is controlled by the [member fps] property as well as each frame's optional delay (see [method set_frame_delay]). The animation loops, i.e. it will restart at frame 0 automatically after playing the last frame.
  9. [code]AnimatedTexture[/code] currently requires all frame textures to have the same size, otherwise the bigger ones will be cropped to match the smallest one.
  10. </description>
  11. <tutorials>
  12. </tutorials>
  13. <demos>
  14. </demos>
  15. <methods>
  16. <method name="get_frame_delay" qualifiers="const">
  17. <return type="float">
  18. </return>
  19. <argument index="0" name="frame" type="int">
  20. </argument>
  21. <description>
  22. Retrieves the delayed assigned to the given [code]frame[/code] ID.
  23. </description>
  24. </method>
  25. <method name="get_frame_texture" qualifiers="const">
  26. <return type="Texture">
  27. </return>
  28. <argument index="0" name="frame" type="int">
  29. </argument>
  30. <description>
  31. Retrieves the [Texture] assigned to the given [code]frame[/code] ID.
  32. </description>
  33. </method>
  34. <method name="set_frame_delay">
  35. <return type="void">
  36. </return>
  37. <argument index="0" name="frame" type="int">
  38. </argument>
  39. <argument index="1" name="delay" type="float">
  40. </argument>
  41. <description>
  42. Defines an additional delay (in seconds) between this frame and the next one, that will be added to the time interval defined by [member 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 [code]1.0 / fps + delay[/code].
  43. 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:
  44. [codeblock]
  45. Frame 0: 0.5 s (1 / fps)
  46. Frame 1: 1.7 s (1 / fps + 1.2)
  47. Frame 2: 0.5 s (1 / fps)
  48. Total duration: 2.7 s
  49. [/codeblock]
  50. </description>
  51. </method>
  52. <method name="set_frame_texture">
  53. <return type="void">
  54. </return>
  55. <argument index="0" name="frame" type="int">
  56. </argument>
  57. <argument index="1" name="texture" type="Texture">
  58. </argument>
  59. <description>
  60. Assigns a [Texture] to the given [code]frame[/code] ID. IDs start at 0 (so the first frame has ID 0, and the last frame of the animation has ID [member frames] - 1).
  61. You can define any frame texture up to [constant MAX_FRAMES], but keep in mind that only frames from 0 to [member frames] - 1 will be part of the animation.
  62. </description>
  63. </method>
  64. </methods>
  65. <members>
  66. <member name="fps" type="float" setter="set_fps" getter="get_fps">
  67. Number of 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 [member 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 [method set_frame_delay]). Default value: 4.
  68. For example, an animation with 8 frames, no frame delay and a [code]fps[/code] value of 2 will run over 4 seconds, with one frame each 0.5 seconds.
  69. </member>
  70. <member name="frames" type="int" setter="set_frames" getter="get_frames">
  71. Number of frames to use in the animation. While you can create the frames independently with [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 [constant MAX_FRAMES]. Default value: 1.
  72. </member>
  73. </members>
  74. <constants>
  75. <constant name="MAX_FRAMES" value="256">
  76. The maximum number of frames supported by [code]AnimatedTexture[/code]. If you need more frames in your animation, use [AnimationPlayer] or [AnimatedSprite].
  77. </constant>
  78. </constants>
  79. </class>