Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
SpriteFrames
Hereda: Resource < RefCounted < Object
Librería de fotogramas de sprite para AnimatedSprite2D y AnimatedSprite3D.
Descripción
Librería de fotogramas de sprite para un nodo AnimatedSprite2D o AnimatedSprite3D. Contiene fotogramas y datos de animación para su reproducción.
Métodos
void |
add_animation(anim: StringName) |
void |
add_frame(anim: StringName, texture: Texture2D, duration: float = 1.0, at_position: int = -1) |
void |
clear(anim: StringName) |
void |
|
void |
duplicate_animation(anim_from: StringName, anim_to: StringName) |
get_animation_loop(anim: StringName) const |
|
get_animation_loop_mode(anim: StringName) const |
|
get_animation_names() const |
|
get_animation_speed(anim: StringName) const |
|
get_frame_count(anim: StringName) const |
|
get_frame_duration(anim: StringName, idx: int) const |
|
get_frame_texture(anim: StringName, idx: int) const |
|
has_animation(anim: StringName) const |
|
void |
remove_animation(anim: StringName) |
void |
remove_frame(anim: StringName, idx: int) |
void |
rename_animation(anim: StringName, newname: StringName) |
void |
set_animation_loop(anim: StringName, loop: bool) |
void |
set_animation_loop_mode(anim: StringName, loop_mode: LoopMode) |
void |
set_animation_speed(anim: StringName, fps: float) |
void |
set_frame(anim: StringName, idx: int, texture: Texture2D, duration: float = 1.0) |
Enumeraciones
enum LoopMode: 🔗
LoopMode LOOP_NONE = 0
The animation plays once and stops when it reaches the end, or the start if played in reverse.
LoopMode LOOP_LINEAR = 1
The animation restarts from the beginning when it reaches the end, or from the end if played in reverse, repeating continuously.
LoopMode LOOP_PINGPONG = 2
The animation alternates direction each time it reaches the end or start, playing forward and then in reverse repeatedly.
Note: Both AnimatedSprite2D and AnimatedSprite3D play the first/last frame for its duration only once at each end of the animation loop (instead of twice, once per forward/backward animation direction).
Descripciones de Métodos
void add_animation(anim: StringName) 🔗
Añade una nueva animación anim a la librería.
void add_frame(anim: StringName, texture: Texture2D, duration: float = 1.0, at_position: int = -1) 🔗
Añade un fotograma a la animación anim. Si at_position es -1, el fotograma se añadirá al final de la animación. duration especifica la duración relativa, véase get_frame_duration() para más detalles.
void clear(anim: StringName) 🔗
Elimina todos los fotogramas de la animación anim.
void clear_all() 🔗
Elimina todas las animaciones. Se creará una animación default vacía.
void duplicate_animation(anim_from: StringName, anim_to: StringName) 🔗
Duplica la animación anim_from a una nueva animación llamada anim_to. Falla si anim_to ya existe, o si anim_from no existe.
bool get_animation_loop(anim: StringName) const 🔗
Obsoleto: Use get_animation_loop_mode() instead.
Returns true if get_animation_loop_mode(anim) == LOOP_LINEAR. Otherwise, returns false.
LoopMode get_animation_loop_mode(anim: StringName) const 🔗
Returns the loop mode for the anim animation.
PackedStringArray get_animation_names() const 🔗
Devuelve un array que contiene los nombres asociados a cada animación. Los valores se colocan en orden alfabético.
float get_animation_speed(anim: StringName) const 🔗
Devuelve la velocidad en fotogramas por segundo para la animación anim.
int get_frame_count(anim: StringName) const 🔗
Devuelve el número de fotogramas para la animación anim.
float get_frame_duration(anim: StringName, idx: int) const 🔗
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:
absolute_duration = relative_duration / (animation_fps * abs(playing_speed))
In this example, playing_speed refers to either AnimatedSprite2D.get_playing_speed() or AnimatedSprite3D.get_playing_speed().
Texture2D get_frame_texture(anim: StringName, idx: int) const 🔗
Devuelve la textura del fotograma idx en la animación anim.
bool has_animation(anim: StringName) const 🔗
Devuelve true si la animación anim existe.
void remove_animation(anim: StringName) 🔗
Elimina la animación anim.
void remove_frame(anim: StringName, idx: int) 🔗
Elimina el fotograma idx de la animación anim.
void rename_animation(anim: StringName, newname: StringName) 🔗
Cambia el nombre de la animación anim a newname.
void set_animation_loop(anim: StringName, loop: bool) 🔗
Obsoleto: Use set_animation_loop_mode() instead.
If loop is false equivalent to set_animation_loop_mode(LOOP_NONE).
If loop is true equivalent to set_animation_loop_mode(LOOP_LINEAR).
void set_animation_loop_mode(anim: StringName, loop_mode: LoopMode) 🔗
Sets the loop_mode for the anim animation.
void set_animation_speed(anim: StringName, fps: float) 🔗
Establece la velocidad para la animación anim en fotogramas por segundo.
void set_frame(anim: StringName, idx: int, texture: Texture2D, duration: float = 1.0) 🔗
Establece la texture y la duration del fotograma idx en la animación anim. duration especifica la duración relativa, véase get_frame_duration() para obtener más detalles.