Sprite frame library for an AnimatedSprite2D or AnimatedSprite3D node. Contains frames and animation data for playback.
Adds a new anim
animation to the library.
Adds a frame to the anim
animation. If at_position
is -1
, the frame will be added to the end of the animation.
Removes all frames from the anim
animation.
Removes all animations. An empty default
animation will be created.
Returns true
if the given animation is configured to loop when it finishes playing. Otherwise, returns false
.
Returns an array containing the names associated to each animation. Values are placed in alphabetical order.
Returns the speed in frames per second for the anim
animation.
Returns the number of frames for the anim
animation.
Returns a relative duration of the frame idx
in the anim
animation (defaults to 1.0
). For example, a frame with a duration of 2.0
is displayed twice as long as a frame with a duration of 1.0
. You can calculate the absolute duration (in seconds) of a frame using the following formula:
In this example, playing_speed
refers to either AnimatedSprite2D.get_playing_speed or AnimatedSprite3D.get_playing_speed.
Returns the texture of the frame idx
in the anim
animation.
Returns true
if the anim
animation exists.
Removes the anim
animation.
Removes the anim
animation's frame idx
.
Changes the anim
animation's name to newname
.
If loop
is true
, the anim
animation will loop when it reaches the end, or the start if it is played in reverse.
Sets the speed for the anim
animation in frames per second.
Sets the texture
and the duration
of the frame idx
in the anim
animation.