:github_url: hide .. Generated automatically by doc/tools/make_rst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the SpriteFrames.xml source instead. .. The source is found in doc/classes or modules//doc_classes. .. _class_SpriteFrames: SpriteFrames ============ **Inherits:** :ref:`Resource` **<** :ref:`RefCounted` **<** :ref:`Object` Sprite frame library for AnimatedSprite2D and AnimatedSprite3D. Description ----------- Sprite frame library for an :ref:`AnimatedSprite2D` or :ref:`AnimatedSprite3D` node. Contains frames and animation data for playback. \ **Note:** You can associate a set of normal or specular maps by creating additional ``SpriteFrames`` resources with a ``_normal`` or ``_specular`` suffix. For example, having 3 ``SpriteFrames`` resources ``run``, ``run_normal``, and ``run_specular`` will make it so the ``run`` animation uses normal and specular maps. Properties ---------- +---------------------------+---------------------------------------------------+ | :ref:`Array` | :ref:`frames` | +---------------------------+---------------------------------------------------+ Methods ------- +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_animation` **(** :ref:`StringName` anim **)** | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_frame` **(** :ref:`StringName` anim, :ref:`Texture2D` frame, :ref:`int` at_position=-1 **)** | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`clear` **(** :ref:`StringName` anim **)** | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`clear_all` **(** **)** | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`get_animation_loop` **(** :ref:`StringName` anim **)** |const| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PackedStringArray` | :ref:`get_animation_names` **(** **)** |const| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`get_animation_speed` **(** :ref:`StringName` anim **)** |const| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Texture2D` | :ref:`get_frame` **(** :ref:`StringName` anim, :ref:`int` idx **)** |const| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_frame_count` **(** :ref:`StringName` anim **)** |const| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`has_animation` **(** :ref:`StringName` anim **)** |const| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`remove_animation` **(** :ref:`StringName` anim **)** | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`remove_frame` **(** :ref:`StringName` anim, :ref:`int` idx **)** | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`rename_animation` **(** :ref:`StringName` anim, :ref:`StringName` newname **)** | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_animation_loop` **(** :ref:`StringName` anim, :ref:`bool` loop **)** | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_animation_speed` **(** :ref:`StringName` anim, :ref:`float` speed **)** | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_frame` **(** :ref:`StringName` anim, :ref:`int` idx, :ref:`Texture2D` txt **)** | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Property Descriptions --------------------- .. _class_SpriteFrames_property_frames: - :ref:`Array` **frames** Compatibility property, always equals to an empty array. Method Descriptions ------------------- .. _class_SpriteFrames_method_add_animation: - void **add_animation** **(** :ref:`StringName` anim **)** Adds a new animation to the library. ---- .. _class_SpriteFrames_method_add_frame: - void **add_frame** **(** :ref:`StringName` anim, :ref:`Texture2D` frame, :ref:`int` at_position=-1 **)** Adds a frame to the given animation. ---- .. _class_SpriteFrames_method_clear: - void **clear** **(** :ref:`StringName` anim **)** Removes all frames from the given animation. ---- .. _class_SpriteFrames_method_clear_all: - void **clear_all** **(** **)** Removes all animations. A "default" animation will be created. ---- .. _class_SpriteFrames_method_get_animation_loop: - :ref:`bool` **get_animation_loop** **(** :ref:`StringName` anim **)** |const| Returns ``true`` if the given animation is configured to loop when it finishes playing. Otherwise, returns ``false``. ---- .. _class_SpriteFrames_method_get_animation_names: - :ref:`PackedStringArray` **get_animation_names** **(** **)** |const| Returns an array containing the names associated to each animation. Values are placed in alphabetical order. ---- .. _class_SpriteFrames_method_get_animation_speed: - :ref:`float` **get_animation_speed** **(** :ref:`StringName` anim **)** |const| The animation's speed in frames per second. ---- .. _class_SpriteFrames_method_get_frame: - :ref:`Texture2D` **get_frame** **(** :ref:`StringName` anim, :ref:`int` idx **)** |const| Returns the animation's selected frame. ---- .. _class_SpriteFrames_method_get_frame_count: - :ref:`int` **get_frame_count** **(** :ref:`StringName` anim **)** |const| Returns the number of frames in the animation. ---- .. _class_SpriteFrames_method_has_animation: - :ref:`bool` **has_animation** **(** :ref:`StringName` anim **)** |const| If ``true``, the named animation exists. ---- .. _class_SpriteFrames_method_remove_animation: - void **remove_animation** **(** :ref:`StringName` anim **)** Removes the given animation. ---- .. _class_SpriteFrames_method_remove_frame: - void **remove_frame** **(** :ref:`StringName` anim, :ref:`int` idx **)** Removes the animation's selected frame. ---- .. _class_SpriteFrames_method_rename_animation: - void **rename_animation** **(** :ref:`StringName` anim, :ref:`StringName` newname **)** Changes the animation's name to ``newname``. ---- .. _class_SpriteFrames_method_set_animation_loop: - void **set_animation_loop** **(** :ref:`StringName` anim, :ref:`bool` loop **)** If ``true``, the animation will loop. ---- .. _class_SpriteFrames_method_set_animation_speed: - void **set_animation_speed** **(** :ref:`StringName` anim, :ref:`float` speed **)** The animation's speed in frames per second. ---- .. _class_SpriteFrames_method_set_frame: - void **set_frame** **(** :ref:`StringName` anim, :ref:`int` idx, :ref:`Texture2D` txt **)** Sets the texture of the given frame. .. |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.)`