Files
godot-docs/classes/class_animatedsprite3d.rst
2022-10-08 13:57:16 +02:00

176 lines
8.3 KiB
ReStructuredText

:github_url: hide
.. DO NOT EDIT THIS FILE!!!
.. Generated automatically from Godot engine sources.
.. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
.. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/AnimatedSprite3D.xml.
.. _class_AnimatedSprite3D:
AnimatedSprite3D
================
**Inherits:** :ref:`SpriteBase3D<class_SpriteBase3D>` **<** :ref:`GeometryInstance3D<class_GeometryInstance3D>` **<** :ref:`VisualInstance3D<class_VisualInstance3D>` **<** :ref:`Node3D<class_Node3D>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
2D sprite node in 3D world, that can use multiple 2D textures for animation.
Description
-----------
``AnimatedSprite3D`` is similar to the :ref:`Sprite3D<class_Sprite3D>` node, except it carries multiple textures as animation :ref:`frames<class_AnimatedSprite3D_property_frames>`. Animations are created using a :ref:`SpriteFrames<class_SpriteFrames>` resource, which allows you to import image files (or a folder containing said files) to provide the animation frames for the sprite. The :ref:`SpriteFrames<class_SpriteFrames>` resource can be configured in the editor via the SpriteFrames bottom panel.
After setting up :ref:`frames<class_AnimatedSprite3D_property_frames>`, :ref:`play<class_AnimatedSprite3D_method_play>` may be called. It's also possible to select an :ref:`animation<class_AnimatedSprite3D_property_animation>` and toggle :ref:`playing<class_AnimatedSprite3D_property_playing>`, even within the editor.
To pause the current animation, call :ref:`stop<class_AnimatedSprite3D_method_stop>` or set :ref:`playing<class_AnimatedSprite3D_property_playing>` to ``false``. Alternatively, setting :ref:`speed_scale<class_AnimatedSprite3D_property_speed_scale>` to ``0`` also preserves the current frame's elapsed time.
Tutorials
---------
- :doc:`2D Sprite animation (also applies to 3D) <../tutorials/2d/2d_sprite_animation>`
Properties
----------
+-----------------------------------------+-----------------------------------------------------------------+----------------+
| :ref:`StringName<class_StringName>` | :ref:`animation<class_AnimatedSprite3D_property_animation>` | ``&"default"`` |
+-----------------------------------------+-----------------------------------------------------------------+----------------+
| :ref:`int<class_int>` | :ref:`frame<class_AnimatedSprite3D_property_frame>` | ``0`` |
+-----------------------------------------+-----------------------------------------------------------------+----------------+
| :ref:`SpriteFrames<class_SpriteFrames>` | :ref:`frames<class_AnimatedSprite3D_property_frames>` | |
+-----------------------------------------+-----------------------------------------------------------------+----------------+
| :ref:`bool<class_bool>` | :ref:`playing<class_AnimatedSprite3D_property_playing>` | ``false`` |
+-----------------------------------------+-----------------------------------------------------------------+----------------+
| :ref:`float<class_float>` | :ref:`speed_scale<class_AnimatedSprite3D_property_speed_scale>` | ``1.0`` |
+-----------------------------------------+-----------------------------------------------------------------+----------------+
Methods
-------
+------+---------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`play<class_AnimatedSprite3D_method_play>` **(** :ref:`StringName<class_StringName>` anim=&"", :ref:`bool<class_bool>` backwards=false **)** |
+------+---------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`stop<class_AnimatedSprite3D_method_stop>` **(** **)** |
+------+---------------------------------------------------------------------------------------------------------------------------------------------------+
Signals
-------
.. _class_AnimatedSprite3D_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_AnimatedSprite3D_signal_frame_changed:
- **frame_changed** **(** **)**
Emitted when :ref:`frame<class_AnimatedSprite3D_property_frame>` changed.
Property Descriptions
---------------------
.. _class_AnimatedSprite3D_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_AnimatedSprite3D_property_frame:
- :ref:`int<class_int>` **frame**
+-----------+------------------+
| *Default* | ``0`` |
+-----------+------------------+
| *Setter* | set_frame(value) |
+-----------+------------------+
| *Getter* | get_frame() |
+-----------+------------------+
The displayed animation frame's index.
----
.. _class_AnimatedSprite3D_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_AnimatedSprite3D_property_playing:
- :ref:`bool<class_bool>` **playing**
+-----------+--------------------+
| *Default* | ``false`` |
+-----------+--------------------+
| *Setter* | set_playing(value) |
+-----------+--------------------+
| *Getter* | is_playing() |
+-----------+--------------------+
If ``true``, the :ref:`animation<class_AnimatedSprite3D_property_animation>` is currently playing. Setting this property to ``false`` is the equivalent of calling :ref:`stop<class_AnimatedSprite3D_method_stop>`.
----
.. _class_AnimatedSprite3D_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. If set to a negative value, the animation is played in reverse. If set to ``0``, the animation is paused, preserving the current frame's elapsed time.
Method Descriptions
-------------------
.. _class_AnimatedSprite3D_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 is played in reverse.
----
.. _class_AnimatedSprite3D_method_stop:
- void **stop** **(** **)**
Stops the current :ref:`animation<class_AnimatedSprite3D_property_animation>` at the current :ref:`frame<class_AnimatedSprite3D_property_frame>`.
\ **Note:** This method resets the current frame's elapsed time. If this behavior is undesired, consider setting :ref:`speed_scale<class_AnimatedSprite3D_property_speed_scale>` to ``0``, instead.
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
.. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`