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
Наследует: Resource < RefCounted < Object
Библиотека кадров спрайтов для AnimatedSprite2D и AnimatedSprite3D.
Описание
Библиотека кадров спрайтов для узла AnimatedSprite2D или AnimatedSprite3D. Содержит кадры и данные анимации для воспроизведения.
Методы
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) |
Перечисления
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).
Описания метода
void add_animation(anim: StringName) 🔗
Добавляет новую анимацию anim в библиотеку.
void add_frame(anim: StringName, texture: Texture2D, duration: float = 1.0, at_position: int = -1) 🔗
Добавляет кадр к анимации anim. Если at_position равен -1, кадр будет добавлен в конец анимации. duration указывает относительную длительность, подробности см. в get_frame_duration().
void clear(anim: StringName) 🔗
Удаляет все кадры из анимации anim.
void clear_all() 🔗
Удаляет все анимации. Будет создана пустая анимация default.
void duplicate_animation(anim_from: StringName, anim_to: StringName) 🔗
Дублирует анимацию anim_from в новую анимацию с именем anim_to. Не выполняется, если anim_to уже существует или если anim_from не существует.
bool get_animation_loop(anim: StringName) const 🔗
Устарело: 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 🔗
Возвращает массив, содержащий имена, связанные с каждой анимацией. Значения располагаются в алфавитном порядке.
float get_animation_speed(anim: StringName) const 🔗
Возвращает скорость в кадрах в секунду для анимации anim.
int get_frame_count(anim: StringName) const 🔗
Возвращает количество кадров для анимации anim.
float get_frame_duration(anim: StringName, idx: int) const 🔗
Возвращает относительную длительность кадра idx в анимации anim (по умолчанию 1.0). Например, кадр с длительностью 2.0 отображается в два раза дольше кадра с длительностью 1.0. Вы можете рассчитать абсолютную длительность (в секундах) кадра, используя следующую формулу:
absolute_duration = relative_duration / (animation_fps * abs(playing_speed))
В этом примере playing_speed относится либо к AnimatedSprite2D.get_playing_speed(), либо к AnimatedSprite3D.get_playing_speed().
Texture2D get_frame_texture(anim: StringName, idx: int) const 🔗
Возвращает текстуру кадра idx в анимации anim.
bool has_animation(anim: StringName) const 🔗
Возвращает true, если анимация anim существует.
void remove_animation(anim: StringName) 🔗
Удаляет анимацию anim.
void remove_frame(anim: StringName, idx: int) 🔗
Удаляет кадр анимации anim idx.
void rename_animation(anim: StringName, newname: StringName) 🔗
Изменяет имя анимации anim на newname.
void set_animation_loop(anim: StringName, loop: bool) 🔗
Устарело: 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) 🔗
Устанавливает скорость анимации anim в кадрах в секунду.
void set_frame(anim: StringName, idx: int, texture: Texture2D, duration: float = 1.0) 🔗
Устанавливает texture и duration кадра idx в анимации anim. duration указывает относительную длительность, подробности см. в get_frame_duration().