mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-04 14:11:02 +03:00
272 lines
10 KiB
ReStructuredText
272 lines
10 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. Generated automatically by doc/tools/makerst.py in Godot's source tree.
|
|
.. DO NOT EDIT THIS FILE, but the AnimatedSprite.xml source instead.
|
|
.. The source is found in doc/classes or modules/<name>/doc_classes.
|
|
|
|
.. _class_AnimatedSprite:
|
|
|
|
AnimatedSprite
|
|
==============
|
|
|
|
**Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
|
|
|
|
Sprite node that can use multiple textures for animation.
|
|
|
|
Description
|
|
-----------
|
|
|
|
Animations are created using a :ref:`SpriteFrames<class_SpriteFrames>` resource, which can be configured in the editor via the SpriteFrames panel.
|
|
|
|
Properties
|
|
----------
|
|
|
|
+-----------------------------------------+---------------------------------------------------------------------+-------------------------+
|
|
| :ref:`StringName<class_StringName>` | :ref:`animation<class_AnimatedSprite_property_animation>` | ``@"default"`` |
|
|
+-----------------------------------------+---------------------------------------------------------------------+-------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`centered<class_AnimatedSprite_property_centered>` | ``true`` |
|
|
+-----------------------------------------+---------------------------------------------------------------------+-------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`flip_h<class_AnimatedSprite_property_flip_h>` | ``false`` |
|
|
+-----------------------------------------+---------------------------------------------------------------------+-------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`flip_v<class_AnimatedSprite_property_flip_v>` | ``false`` |
|
|
+-----------------------------------------+---------------------------------------------------------------------+-------------------------+
|
|
| :ref:`int<class_int>` | :ref:`frame<class_AnimatedSprite_property_frame>` | ``0`` |
|
|
+-----------------------------------------+---------------------------------------------------------------------+-------------------------+
|
|
| :ref:`SpriteFrames<class_SpriteFrames>` | :ref:`frames<class_AnimatedSprite_property_frames>` | |
|
|
+-----------------------------------------+---------------------------------------------------------------------+-------------------------+
|
|
| :ref:`Vector2<class_Vector2>` | :ref:`offset<class_AnimatedSprite_property_offset>` | ``Vector2( 0, 0 )`` |
|
|
+-----------------------------------------+---------------------------------------------------------------------+-------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`playing<class_AnimatedSprite_property_playing>` | ``false`` |
|
|
+-----------------------------------------+---------------------------------------------------------------------+-------------------------+
|
|
| :ref:`float<class_float>` | :ref:`shininess<class_AnimatedSprite_property_shininess>` | ``1.0`` |
|
|
+-----------------------------------------+---------------------------------------------------------------------+-------------------------+
|
|
| :ref:`Color<class_Color>` | :ref:`specular_color<class_AnimatedSprite_property_specular_color>` | ``Color( 1, 1, 1, 1 )`` |
|
|
+-----------------------------------------+---------------------------------------------------------------------+-------------------------+
|
|
| :ref:`float<class_float>` | :ref:`speed_scale<class_AnimatedSprite_property_speed_scale>` | ``1.0`` |
|
|
+-----------------------------------------+---------------------------------------------------------------------+-------------------------+
|
|
|
|
Methods
|
|
-------
|
|
|
|
+-------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`is_playing<class_AnimatedSprite_method_is_playing>` **(** **)** const |
|
|
+-------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`play<class_AnimatedSprite_method_play>` **(** :ref:`StringName<class_StringName>` anim=@"", :ref:`bool<class_bool>` backwards=false **)** |
|
|
+-------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`stop<class_AnimatedSprite_method_stop>` **(** **)** |
|
|
+-------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
Signals
|
|
-------
|
|
|
|
.. _class_AnimatedSprite_signal_animation_finished:
|
|
|
|
- **animation_finished** **(** **)**
|
|
|
|
Emitted when the animation is finished (when it plays the last frame). If the animation is looping, this signal is emitted every time the last frame is drawn.
|
|
|
|
----
|
|
|
|
.. _class_AnimatedSprite_signal_frame_changed:
|
|
|
|
- **frame_changed** **(** **)**
|
|
|
|
Emitted when :ref:`frame<class_AnimatedSprite_property_frame>` changed.
|
|
|
|
Property Descriptions
|
|
---------------------
|
|
|
|
.. _class_AnimatedSprite_property_animation:
|
|
|
|
- :ref:`StringName<class_StringName>` **animation**
|
|
|
|
+-----------+----------------------+
|
|
| *Default* | ``@"default"`` |
|
|
+-----------+----------------------+
|
|
| *Setter* | set_animation(value) |
|
|
+-----------+----------------------+
|
|
| *Getter* | get_animation() |
|
|
+-----------+----------------------+
|
|
|
|
The current animation from the ``frames`` resource. If this value changes, the ``frame`` counter is reset.
|
|
|
|
----
|
|
|
|
.. _class_AnimatedSprite_property_centered:
|
|
|
|
- :ref:`bool<class_bool>` **centered**
|
|
|
|
+-----------+---------------------+
|
|
| *Default* | ``true`` |
|
|
+-----------+---------------------+
|
|
| *Setter* | set_centered(value) |
|
|
+-----------+---------------------+
|
|
| *Getter* | is_centered() |
|
|
+-----------+---------------------+
|
|
|
|
If ``true``, texture will be centered.
|
|
|
|
----
|
|
|
|
.. _class_AnimatedSprite_property_flip_h:
|
|
|
|
- :ref:`bool<class_bool>` **flip_h**
|
|
|
|
+-----------+-------------------+
|
|
| *Default* | ``false`` |
|
|
+-----------+-------------------+
|
|
| *Setter* | set_flip_h(value) |
|
|
+-----------+-------------------+
|
|
| *Getter* | is_flipped_h() |
|
|
+-----------+-------------------+
|
|
|
|
If ``true``, texture is flipped horizontally.
|
|
|
|
----
|
|
|
|
.. _class_AnimatedSprite_property_flip_v:
|
|
|
|
- :ref:`bool<class_bool>` **flip_v**
|
|
|
|
+-----------+-------------------+
|
|
| *Default* | ``false`` |
|
|
+-----------+-------------------+
|
|
| *Setter* | set_flip_v(value) |
|
|
+-----------+-------------------+
|
|
| *Getter* | is_flipped_v() |
|
|
+-----------+-------------------+
|
|
|
|
If ``true``, texture is flipped vertically.
|
|
|
|
----
|
|
|
|
.. _class_AnimatedSprite_property_frame:
|
|
|
|
- :ref:`int<class_int>` **frame**
|
|
|
|
+-----------+------------------+
|
|
| *Default* | ``0`` |
|
|
+-----------+------------------+
|
|
| *Setter* | set_frame(value) |
|
|
+-----------+------------------+
|
|
| *Getter* | get_frame() |
|
|
+-----------+------------------+
|
|
|
|
The displayed animation frame's index.
|
|
|
|
----
|
|
|
|
.. _class_AnimatedSprite_property_frames:
|
|
|
|
- :ref:`SpriteFrames<class_SpriteFrames>` **frames**
|
|
|
|
+----------+--------------------------+
|
|
| *Setter* | set_sprite_frames(value) |
|
|
+----------+--------------------------+
|
|
| *Getter* | get_sprite_frames() |
|
|
+----------+--------------------------+
|
|
|
|
The :ref:`SpriteFrames<class_SpriteFrames>` resource containing the animation(s).
|
|
|
|
----
|
|
|
|
.. _class_AnimatedSprite_property_offset:
|
|
|
|
- :ref:`Vector2<class_Vector2>` **offset**
|
|
|
|
+-----------+---------------------+
|
|
| *Default* | ``Vector2( 0, 0 )`` |
|
|
+-----------+---------------------+
|
|
| *Setter* | set_offset(value) |
|
|
+-----------+---------------------+
|
|
| *Getter* | get_offset() |
|
|
+-----------+---------------------+
|
|
|
|
The texture's drawing offset.
|
|
|
|
----
|
|
|
|
.. _class_AnimatedSprite_property_playing:
|
|
|
|
- :ref:`bool<class_bool>` **playing**
|
|
|
|
+-----------+-----------+
|
|
| *Default* | ``false`` |
|
|
+-----------+-----------+
|
|
|
|
If ``true``, the :ref:`animation<class_AnimatedSprite_property_animation>` is currently playing.
|
|
|
|
----
|
|
|
|
.. _class_AnimatedSprite_property_shininess:
|
|
|
|
- :ref:`float<class_float>` **shininess**
|
|
|
|
+-----------+----------------------+
|
|
| *Default* | ``1.0`` |
|
|
+-----------+----------------------+
|
|
| *Setter* | set_shininess(value) |
|
|
+-----------+----------------------+
|
|
| *Getter* | get_shininess() |
|
|
+-----------+----------------------+
|
|
|
|
Strength of the specular light effect of this ``AnimatedSprite``.
|
|
|
|
----
|
|
|
|
.. _class_AnimatedSprite_property_specular_color:
|
|
|
|
- :ref:`Color<class_Color>` **specular_color**
|
|
|
|
+-----------+---------------------------+
|
|
| *Default* | ``Color( 1, 1, 1, 1 )`` |
|
|
+-----------+---------------------------+
|
|
| *Setter* | set_specular_color(value) |
|
|
+-----------+---------------------------+
|
|
| *Getter* | get_specular_color() |
|
|
+-----------+---------------------------+
|
|
|
|
The color of the specular light effect.
|
|
|
|
----
|
|
|
|
.. _class_AnimatedSprite_property_speed_scale:
|
|
|
|
- :ref:`float<class_float>` **speed_scale**
|
|
|
|
+-----------+------------------------+
|
|
| *Default* | ``1.0`` |
|
|
+-----------+------------------------+
|
|
| *Setter* | set_speed_scale(value) |
|
|
+-----------+------------------------+
|
|
| *Getter* | get_speed_scale() |
|
|
+-----------+------------------------+
|
|
|
|
The animation speed is multiplied by this value.
|
|
|
|
Method Descriptions
|
|
-------------------
|
|
|
|
.. _class_AnimatedSprite_method_is_playing:
|
|
|
|
- :ref:`bool<class_bool>` **is_playing** **(** **)** const
|
|
|
|
Returns ``true`` if an animation is currently being played.
|
|
|
|
----
|
|
|
|
.. _class_AnimatedSprite_method_play:
|
|
|
|
- void **play** **(** :ref:`StringName<class_StringName>` anim=@"", :ref:`bool<class_bool>` backwards=false **)**
|
|
|
|
Plays the animation named ``anim``. If no ``anim`` is provided, the current animation is played. If ``backwards`` is ``true``, the animation will be played in reverse.
|
|
|
|
----
|
|
|
|
.. _class_AnimatedSprite_method_stop:
|
|
|
|
- void **stop** **(** **)**
|
|
|
|
Stops the current animation (does not reset the frame counter).
|
|
|