godot/doc/classes/AnimatedTexture.xml

71 lines
4.3 KiB
XML

<?xml version="1.0" encoding="UTF-8" ?>
<class name="AnimatedTexture" inherits="Texture2D" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
Proxy texture for simple frame-based animations.
</brief_description>
<description>
[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].
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.
[AnimatedTexture] currently requires all frame textures to have the same size, otherwise the bigger ones will be cropped to match the smallest one.
[b]Note:[/b] AnimatedTexture doesn't support using [AtlasTexture]s. Each frame needs to be a separate [Texture2D].
</description>
<tutorials>
</tutorials>
<methods>
<method name="get_frame_duration" qualifiers="const">
<return type="float" />
<param index="0" name="frame" type="int" />
<description>
Returns the given [param frame]'s duration, in seconds.
</description>
</method>
<method name="get_frame_texture" qualifiers="const">
<return type="Texture2D" />
<param index="0" name="frame" type="int" />
<description>
Returns the given frame's [Texture2D].
</description>
</method>
<method name="set_frame_duration">
<return type="void" />
<param index="0" name="frame" type="int" />
<param index="1" name="duration" type="float" />
<description>
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.
</description>
</method>
<method name="set_frame_texture">
<return type="void" />
<param index="0" name="frame" type="int" />
<param index="1" name="texture" type="Texture2D" />
<description>
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.
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.
</description>
</method>
</methods>
<members>
<member name="current_frame" type="int" setter="set_current_frame" getter="get_current_frame">
Sets the currently visible frame of the texture.
</member>
<member name="frames" type="int" setter="set_frames" getter="get_frames" default="1">
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].
</member>
<member name="one_shot" type="bool" setter="set_one_shot" getter="get_one_shot" default="false">
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].
</member>
<member name="pause" type="bool" setter="set_pause" getter="get_pause" default="false">
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].
</member>
<member name="resource_local_to_scene" type="bool" setter="set_local_to_scene" getter="is_local_to_scene" overrides="Resource" default="false" />
<member name="speed_scale" type="float" setter="set_speed_scale" getter="get_speed_scale" default="1.0">
The animation speed is multiplied by this value. If set to a negative value, the animation is played in reverse.
</member>
</members>
<constants>
<constant name="MAX_FRAMES" value="256">
The maximum number of frames supported by [AnimatedTexture]. If you need more frames in your animation, use [AnimationPlayer] or [AnimatedSprite2D].
</constant>
</constants>
</class>