Files
godot-docs-l10n/classes/uk/class_spriteframes.rst

301 lines
21 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

:github_url: hide
.. _class_SpriteFrames:
SpriteFrames
============
**Успадковує:** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
Бібліотека кадрів спрайтів для AnimatedSprite2D і AnimatedSprite3D.
.. rst-class:: classref-introduction-group
Опис
--------
Бібліотека кадрів спрайтів для вузла :ref:`AnimatedSprite2D<class_AnimatedSprite2D>` або :ref:`AnimatedSprite3D<class_AnimatedSprite3D>`. Містить кадри та дані анімації для відтворення.
.. rst-class:: classref-reftable-group
Методи
------------
.. table::
:widths: auto
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`add_animation<class_SpriteFrames_method_add_animation>`\ (\ anim\: :ref:`StringName<class_StringName>`\ ) |
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`add_frame<class_SpriteFrames_method_add_frame>`\ (\ anim\: :ref:`StringName<class_StringName>`, texture\: :ref:`Texture2D<class_Texture2D>`, duration\: :ref:`float<class_float>` = 1.0, at_position\: :ref:`int<class_int>` = -1\ ) |
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`clear<class_SpriteFrames_method_clear>`\ (\ anim\: :ref:`StringName<class_StringName>`\ ) |
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`clear_all<class_SpriteFrames_method_clear_all>`\ (\ ) |
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`duplicate_animation<class_SpriteFrames_method_duplicate_animation>`\ (\ anim_from\: :ref:`StringName<class_StringName>`, anim_to\: :ref:`StringName<class_StringName>`\ ) |
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`get_animation_loop<class_SpriteFrames_method_get_animation_loop>`\ (\ anim\: :ref:`StringName<class_StringName>`\ ) |const| |
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_animation_names<class_SpriteFrames_method_get_animation_names>`\ (\ ) |const| |
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`get_animation_speed<class_SpriteFrames_method_get_animation_speed>`\ (\ anim\: :ref:`StringName<class_StringName>`\ ) |const| |
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`get_frame_count<class_SpriteFrames_method_get_frame_count>`\ (\ anim\: :ref:`StringName<class_StringName>`\ ) |const| |
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`get_frame_duration<class_SpriteFrames_method_get_frame_duration>`\ (\ anim\: :ref:`StringName<class_StringName>`, idx\: :ref:`int<class_int>`\ ) |const| |
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Texture2D<class_Texture2D>` | :ref:`get_frame_texture<class_SpriteFrames_method_get_frame_texture>`\ (\ anim\: :ref:`StringName<class_StringName>`, idx\: :ref:`int<class_int>`\ ) |const| |
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`has_animation<class_SpriteFrames_method_has_animation>`\ (\ anim\: :ref:`StringName<class_StringName>`\ ) |const| |
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`remove_animation<class_SpriteFrames_method_remove_animation>`\ (\ anim\: :ref:`StringName<class_StringName>`\ ) |
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`remove_frame<class_SpriteFrames_method_remove_frame>`\ (\ anim\: :ref:`StringName<class_StringName>`, idx\: :ref:`int<class_int>`\ ) |
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`rename_animation<class_SpriteFrames_method_rename_animation>`\ (\ anim\: :ref:`StringName<class_StringName>`, newname\: :ref:`StringName<class_StringName>`\ ) |
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`set_animation_loop<class_SpriteFrames_method_set_animation_loop>`\ (\ anim\: :ref:`StringName<class_StringName>`, loop\: :ref:`bool<class_bool>`\ ) |
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`set_animation_speed<class_SpriteFrames_method_set_animation_speed>`\ (\ anim\: :ref:`StringName<class_StringName>`, fps\: :ref:`float<class_float>`\ ) |
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`set_frame<class_SpriteFrames_method_set_frame>`\ (\ anim\: :ref:`StringName<class_StringName>`, idx\: :ref:`int<class_int>`, texture\: :ref:`Texture2D<class_Texture2D>`, duration\: :ref:`float<class_float>` = 1.0\ ) |
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Описи методів
--------------------------
.. _class_SpriteFrames_method_add_animation:
.. rst-class:: classref-method
|void| **add_animation**\ (\ anim\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_SpriteFrames_method_add_animation>`
Додавання нової анімації ``anim`` до бібліотеки.
.. rst-class:: classref-item-separator
----
.. _class_SpriteFrames_method_add_frame:
.. rst-class:: classref-method
|void| **add_frame**\ (\ anim\: :ref:`StringName<class_StringName>`, texture\: :ref:`Texture2D<class_Texture2D>`, duration\: :ref:`float<class_float>` = 1.0, at_position\: :ref:`int<class_int>` = -1\ ) :ref:`🔗<class_SpriteFrames_method_add_frame>`
Додає кадр до анімації ``anim``. Якщо ``at_position`` має значення ``-1``, кадр буде додано в кінець анімації. ``duration`` визначає відносну тривалість, див. :ref:`get_frame_duration()<class_SpriteFrames_method_get_frame_duration>` для отримання детальної інформації.
.. rst-class:: classref-item-separator
----
.. _class_SpriteFrames_method_clear:
.. rst-class:: classref-method
|void| **clear**\ (\ anim\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_SpriteFrames_method_clear>`
Видалити всі кадри з анімації ``anim``.
.. rst-class:: classref-item-separator
----
.. _class_SpriteFrames_method_clear_all:
.. rst-class:: classref-method
|void| **clear_all**\ (\ ) :ref:`🔗<class_SpriteFrames_method_clear_all>`
Видалити всі анімації. Створено порожній ``default`` анімації.
.. rst-class:: classref-item-separator
----
.. _class_SpriteFrames_method_duplicate_animation:
.. rst-class:: classref-method
|void| **duplicate_animation**\ (\ anim_from\: :ref:`StringName<class_StringName>`, anim_to\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_SpriteFrames_method_duplicate_animation>`
Дублює анімацію ``anim_from`` у нову анімацію з назвою ``anim_to``. Помилка, якщо ``anim_to`` вже існує або якщо ``anim_from`` не існує.
.. rst-class:: classref-item-separator
----
.. _class_SpriteFrames_method_get_animation_loop:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **get_animation_loop**\ (\ anim\: :ref:`StringName<class_StringName>`\ ) |const| :ref:`🔗<class_SpriteFrames_method_get_animation_loop>`
Повертає ``true``, якщо дана анімація налаштована на петлю, коли вона закінчує гру. В іншому випадку повертається ``false``.
.. rst-class:: classref-item-separator
----
.. _class_SpriteFrames_method_get_animation_names:
.. rst-class:: classref-method
:ref:`PackedStringArray<class_PackedStringArray>` **get_animation_names**\ (\ ) |const| :ref:`🔗<class_SpriteFrames_method_get_animation_names>`
Повертає масив, що містить імена, пов'язані з кожним анімацією. Значення розміщуються в алфавітному порядку.
.. rst-class:: classref-item-separator
----
.. _class_SpriteFrames_method_get_animation_speed:
.. rst-class:: classref-method
:ref:`float<class_float>` **get_animation_speed**\ (\ anim\: :ref:`StringName<class_StringName>`\ ) |const| :ref:`🔗<class_SpriteFrames_method_get_animation_speed>`
Повертає швидкість в кадрах на секунду для анімації ``anim``.
.. rst-class:: classref-item-separator
----
.. _class_SpriteFrames_method_get_frame_count:
.. rst-class:: classref-method
:ref:`int<class_int>` **get_frame_count**\ (\ anim\: :ref:`StringName<class_StringName>`\ ) |const| :ref:`🔗<class_SpriteFrames_method_get_frame_count>`
Повернення кількості кадрів для анімації ``anim``.
.. rst-class:: classref-item-separator
----
.. _class_SpriteFrames_method_get_frame_duration:
.. rst-class:: classref-method
:ref:`float<class_float>` **get_frame_duration**\ (\ anim\: :ref:`StringName<class_StringName>`, idx\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_SpriteFrames_method_get_frame_duration>`
Повертає відносну тривалість кадру ``idx`` в анімації ``anim`` (за замовчуванням ``1.0``). Наприклад, кадр тривалістю ``2.0`` відображається вдвічі довший за кадр тривалістю ``1.0``. Ви можете обчислити абсолютну тривалість (у секундах) кадру за такою формулою:
::
absolute_duration = relative_duration / (animation_fps * abs(playing_speed))
У цьому прикладі ``playing_speed`` стосується або :ref:`AnimatedSprite2D.get_playing_speed()<class_AnimatedSprite2D_method_get_playing_speed>`, або :ref:`AnimatedSprite3D.get_playing_speed()<class_AnimatedSprite3D_method_get_playing_speed>`.
.. rst-class:: classref-item-separator
----
.. _class_SpriteFrames_method_get_frame_texture:
.. rst-class:: classref-method
:ref:`Texture2D<class_Texture2D>` **get_frame_texture**\ (\ anim\: :ref:`StringName<class_StringName>`, idx\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_SpriteFrames_method_get_frame_texture>`
Повернення текстури кадру ``idx`` в анімації ``anim``.
.. rst-class:: classref-item-separator
----
.. _class_SpriteFrames_method_has_animation:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **has_animation**\ (\ anim\: :ref:`StringName<class_StringName>`\ ) |const| :ref:`🔗<class_SpriteFrames_method_has_animation>`
Повернення ``true`` якщо існує анімація ``anim``.
.. rst-class:: classref-item-separator
----
.. _class_SpriteFrames_method_remove_animation:
.. rst-class:: classref-method
|void| **remove_animation**\ (\ anim\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_SpriteFrames_method_remove_animation>`
Вилучає анімацію ``anim``.
.. rst-class:: classref-item-separator
----
.. _class_SpriteFrames_method_remove_frame:
.. rst-class:: classref-method
|void| **remove_frame**\ (\ anim\: :ref:`StringName<class_StringName>`, idx\: :ref:`int<class_int>`\ ) :ref:`🔗<class_SpriteFrames_method_remove_frame>`
Вилучає рамку анімації ``idx``.
.. rst-class:: classref-item-separator
----
.. _class_SpriteFrames_method_rename_animation:
.. rst-class:: classref-method
|void| **rename_animation**\ (\ anim\: :ref:`StringName<class_StringName>`, newname\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_SpriteFrames_method_rename_animation>`
Зміни ім'я анімації ``anim`` на ``newname``.
.. rst-class:: classref-item-separator
----
.. _class_SpriteFrames_method_set_animation_loop:
.. rst-class:: classref-method
|void| **set_animation_loop**\ (\ anim\: :ref:`StringName<class_StringName>`, loop\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_SpriteFrames_method_set_animation_loop>`
Якщо ``петлі`` є ``true``, то ``anim`` анімація буде петлю, коли він досягає кінця, або початок, якщо він грає в зворотному напрямку.
.. rst-class:: classref-item-separator
----
.. _class_SpriteFrames_method_set_animation_speed:
.. rst-class:: classref-method
|void| **set_animation_speed**\ (\ anim\: :ref:`StringName<class_StringName>`, fps\: :ref:`float<class_float>`\ ) :ref:`🔗<class_SpriteFrames_method_set_animation_speed>`
Налаштовує швидкість анімації ``anim`` в кадрах на секунду.
.. rst-class:: classref-item-separator
----
.. _class_SpriteFrames_method_set_frame:
.. rst-class:: classref-method
|void| **set_frame**\ (\ anim\: :ref:`StringName<class_StringName>`, idx\: :ref:`int<class_int>`, texture\: :ref:`Texture2D<class_Texture2D>`, duration\: :ref:`float<class_float>` = 1.0\ ) :ref:`🔗<class_SpriteFrames_method_set_frame>`
Встановлює ``texture`` та ``duration`` кадру ``idx`` в анімації ``anim``. ``duration`` визначає відносну тривалість, див. :ref:`get_frame_duration()<class_SpriteFrames_method_get_frame_duration>` для отримання детальної інформації.
.. |virtual| replace:: :abbr:`virtual (Зазвичай, цей метод перевизначається користувачем, щоб він мав вплив.)`
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
.. |const| replace:: :abbr:`const (Цей метод не має побічних ефектів. Не змінює ніяку змінну екземпляра об'єкта.)`
.. |vararg| replace:: :abbr:`vararg (Цей метод приймає будь-яке число аргументів після описаних тут.)`
.. |constructor| replace:: :abbr:`constructor (Цей метод використовується для побудови типів.)`
.. |static| replace:: :abbr:`static (Цей метод не потребує екземпляра для виклику, його можна викликати безпосередньо за допомогою назви класу.)`
.. |operator| replace:: :abbr:`operator (Цей метод описує дійсний оператор для взаємодії з цим типом як з лівим операндом.)`
.. |bitfield| replace:: :abbr:`BitField (Це значення є цілим числом, складеним у вигляді бітової маски з наступних прапорів.)`
.. |void| replace:: :abbr:`void (Значення не повертається.)`