0.2.0-dev Download ZIP
71 lines ·4.7 KB Raw
| 1 | <?xml version="1.0" encoding="UTF-8" ?> |
| 2 | <class name="AnimatedTexture" inherits="Texture2D" api_type="core" deprecated="This class does not work properly in current versions and may be removed in the future. There is currently no equivalent workaround." xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> |
| 3 | <brief_description> |
| 4 | Proxy texture for simple frame-based animations. |
| 5 | </brief_description> |
| 6 | <description> |
| 7 | [AnimatedTexture] is a resource format for frame-based animations, where multiple textures can be chained automatically with a predefined delay for each frame. Unlike [AnimationPlayer] or [AnimatedSprite2D], it isn't a [Node], but has the advantage of being usable anywhere a [Texture2D] resource can be used, e.g. in a [TileSet]. |
| 8 | The playback of the animation is controlled by the [member speed_scale] property, as well as each frame's duration (see [method set_frame_duration]). The animation loops, i.e. it will restart at frame 0 automatically after playing the last frame. |
| 9 | [AnimatedTexture] currently requires all frame textures to have the same size, otherwise the bigger ones will be cropped to match the smallest one. |
| 10 | [b]Note:[/b] AnimatedTexture doesn't support using [AtlasTexture]s. Each frame needs to be a separate [Texture2D]. |
| 11 | [b]Warning:[/b] The current implementation is not efficient for the modern renderers. |
| 12 | </description> |
| 13 | <tutorials> |
| 14 | </tutorials> |
| 15 | <methods> |
| 16 | <method name="get_frame_duration" qualifiers="const"> |
| 17 | <return type="float" /> |
| 18 | <param index="0" name="frame" type="int" /> |
| 19 | <description> |
| 20 | Returns the given [param frame]'s duration, in seconds. |
| 21 | </description> |
| 22 | </method> |
| 23 | <method name="get_frame_texture" qualifiers="const"> |
| 24 | <return type="Texture2D" /> |
| 25 | <param index="0" name="frame" type="int" /> |
| 26 | <description> |
| 27 | Returns the given frame's [Texture2D]. |
| 28 | </description> |
| 29 | </method> |
| 30 | <method name="set_frame_duration"> |
| 31 | <return type="void" /> |
| 32 | <param index="0" name="frame" type="int" /> |
| 33 | <param index="1" name="duration" type="float" /> |
| 34 | <description> |
| 35 | Sets the duration of any given [param frame]. The final duration is affected by the [member speed_scale]. If set to [code]0[/code], the frame is skipped during playback. |
| 36 | </description> |
| 37 | </method> |
| 38 | <method name="set_frame_texture"> |
| 39 | <return type="void" /> |
| 40 | <param index="0" name="frame" type="int" /> |
| 41 | <param index="1" name="texture" type="Texture2D" /> |
| 42 | <description> |
| 43 | Assigns a [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 [member frames] - 1. |
| 44 | You can define any number of textures up to [constant MAX_FRAMES], but keep in mind that only frames from 0 to [member frames] - 1 will be part of the animation. |
| 45 | </description> |
| 46 | </method> |
| 47 | </methods> |
| 48 | <members> |
| 49 | <member name="current_frame" type="int" setter="set_current_frame" getter="get_current_frame"> |
| 50 | 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. |
| 51 | </member> |
| 52 | <member name="frames" type="int" setter="set_frames" getter="get_frames" default="1"> |
| 53 | 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]. |
| 54 | </member> |
| 55 | <member name="one_shot" type="bool" setter="set_one_shot" getter="get_one_shot" default="false"> |
| 56 | If [code]true[/code], 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 [member pause] to [code]true[/code]. |
| 57 | </member> |
| 58 | <member name="pause" type="bool" setter="set_pause" getter="get_pause" default="false"> |
| 59 | If [code]true[/code], the animation will pause where it currently is (i.e. at [member current_frame]). The animation will continue from where it was paused when changing this property to [code]false[/code]. |
| 60 | </member> |
| 61 | <member name="resource_local_to_scene" type="bool" setter="set_local_to_scene" getter="is_local_to_scene" overrides="Resource" default="false" /> |
| 62 | <member name="speed_scale" type="float" setter="set_speed_scale" getter="get_speed_scale" default="1.0"> |
| 63 | The animation speed is multiplied by this value. If set to a negative value, the animation is played in reverse. |
| 64 | </member> |
| 65 | </members> |
| 66 | <constants> |
| 67 | <constant name="MAX_FRAMES" value="256"> |
| 68 | The maximum number of frames supported by [AnimatedTexture]. If you need more frames in your animation, use [AnimationPlayer] or [AnimatedSprite2D]. |
| 69 | </constant> |
| 70 | </constants> |
| 71 | </class> |