AnimatedSprite

Inherits: Node2D < CanvasItem < Node < Object

Sprite node that can use multiple textures for animation.

Description

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

Note: You can associate a set of normal maps by creating additional SpriteFrames resources with a _normal suffix. For example, having 2 SpriteFrames resources run and run_normal will make it so the run animation uses the normal map.

Tutorials

Properties

Stringanimation“default”
boolcenteredtrue
boolflip_hfalse
boolflip_vfalse
intframe0
SpriteFramesframes 
Vector2offsetVector2( 0, 0 )
boolplayingfalse
floatspeed_scale1.0

Methods

boolis_playing ( ) const
voidplay ( String anim=””, bool backwards=false )
voidstop ( )

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.

Property Descriptions

Default“default”
Setterset_animation(value)
Getterget_animation()

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


Defaulttrue
Setterset_centered(value)
Getteris_centered()

If true, texture will be centered.


Defaultfalse
Setterset_flip_h(value)
Getteris_flipped_h()

If true, texture is flipped horizontally.


Defaultfalse
Setterset_flip_v(value)
Getteris_flipped_v()

If true, texture is flipped vertically.


Default0
Setterset_frame(value)
Getterget_frame()

The displayed animation frame’s index.


Setterset_sprite_frames(value)
Getterget_sprite_frames()

The SpriteFrames resource containing the animation(s).


DefaultVector2( 0, 0 )
Setterset_offset(value)
Getterget_offset()

The texture’s drawing offset.


Defaultfalse

If true, the animation is currently playing.


Default1.0
Setterset_speed_scale(value)
Getterget_speed_scale()

The animation speed is multiplied by this value.

Method Descriptions

  • bool is_playing ( ) const

Returns true if an animation is currently being played.


  • void play ( String anim=””, 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.


  • void stop ( )

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