SpriteFrames¶
Inherits: Resource < RefCounted < Object
Sprite frame library for AnimatedSprite2D and AnimatedSprite3D.
Description¶
Sprite frame library for an AnimatedSprite2D or AnimatedSprite3D node. Contains frames and animation data for playback.
Note: You can associate a set of normal or specular maps by creating additional SpriteFrames
resources with a _normal
or _specular
suffix. For example, having 3 SpriteFrames
resources run
, run_normal
, and run_specular
will make it so the run
animation uses normal and specular maps.
Properties¶
Methods¶
void |
add_animation ( StringName anim ) |
void |
add_frame ( StringName anim, Texture2D frame, int at_position=-1 ) |
void |
clear ( StringName anim ) |
void |
clear_all ( ) |
get_animation_loop ( StringName anim ) const |
|
get_animation_names ( ) const |
|
get_animation_speed ( StringName anim ) const |
|
get_frame ( StringName anim, int idx ) const |
|
get_frame_count ( StringName anim ) const |
|
has_animation ( StringName anim ) const |
|
void |
remove_animation ( StringName anim ) |
void |
remove_frame ( StringName anim, int idx ) |
void |
rename_animation ( StringName anim, StringName newname ) |
void |
set_animation_loop ( StringName anim, bool loop ) |
void |
set_animation_speed ( StringName anim, float speed ) |
void |
set_frame ( StringName anim, int idx, Texture2D txt ) |
Property Descriptions¶
Array frames
Compatibility property, always equals to an empty array.
Method Descriptions¶
void add_animation ( StringName anim )
Adds a new animation to the library.
void add_frame ( StringName anim, Texture2D frame, int at_position=-1 )
Adds a frame to the given animation.
void clear ( StringName anim )
Removes all frames from the given animation.
void clear_all ( )
Removes all animations. A "default" animation will be created.
bool get_animation_loop ( StringName anim ) const
Returns true
if the given animation is configured to loop when it finishes playing. Otherwise, returns false
.
PackedStringArray get_animation_names ( ) const
Returns an array containing the names associated to each animation. Values are placed in alphabetical order.
float get_animation_speed ( StringName anim ) const
The animation's speed in frames per second.
Texture2D get_frame ( StringName anim, int idx ) const
Returns the animation's selected frame.
int get_frame_count ( StringName anim ) const
Returns the number of frames in the animation.
bool has_animation ( StringName anim ) const
If true
, the named animation exists.
void remove_animation ( StringName anim )
Removes the given animation.
void remove_frame ( StringName anim, int idx )
Removes the animation's selected frame.
void rename_animation ( StringName anim, StringName newname )
Changes the animation's name to newname
.
void set_animation_loop ( StringName anim, bool loop )
If true
, the animation will loop.
void set_animation_speed ( StringName anim, float speed )
The animation's speed in frames per second.
void set_frame ( StringName anim, int idx, Texture2D txt )
Sets the texture of the given frame.