AnimatedSprite

Inherits: Node2D < CanvasItem < Node < Object

Category: Core

Brief Description

Sprite node that can use multiple textures for animation.

Methods

bool is_playing ( ) const
void play ( String anim=””, bool backwards=false )
void stop ( )

Signals

  • 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.


  • frame_changed ( )

Emitted when frame changed.

Description

Animations are created using a SpriteFrames resource, which can be configured in the editor via the SpriteFrames panel.

Property Descriptions

Setter set_animation(value)
Getter get_animation()

The current animation from the frames resource. If this value changes, the frame counter is reset.


Setter set_centered(value)
Getter is_centered()

If true, texture will be centered. Default value: true.


Setter set_flip_h(value)
Getter is_flipped_h()

If true, texture is flipped horizontally. Default value: false.


Setter set_flip_v(value)
Getter is_flipped_v()

If true, texture is flipped vertically. Default value: false.


Setter set_frame(value)
Getter get_frame()

The displayed animation frame’s index.


Setter set_sprite_frames(value)
Getter get_sprite_frames()

The SpriteFrames resource containing the animation(s).


Setter set_offset(value)
Getter get_offset()

The texture’s drawing offset.


If true, the animation is currently playing.


Setter set_speed_scale(value)
Getter get_speed_scale()

The animation speed is multiplied by this value.

Method Descriptions

  • bool is_playing ( ) const

Returns true if an animation if currently being played.


  • void play ( String anim=””, bool backwards=false )

Play the animation set in parameter. If no parameter is provided, the current animation is played. Property backwards plays the animation in reverse if set to true.


  • void stop ( )

Stop the current animation (does not reset the frame counter).