AnimatedSprite
Inherits: Node2D < CanvasItem < Node < Object Sprite node that contains multiple textures as frames to play for animation.
Description
AnimatedSprite is similar to the Sprite node, except it carries multiple textures as animation frames. Animations are created using a SpriteFrames resource, which allows you to import image files (or a folder containing said files) to provide the animation frames for the sprite. The SpriteFrames resource can be configured in the editor via the SpriteFrames bottom panel.
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.
Tutorials
- 2D Sprite animation
- 2D Dodge The Creeps Demo
Properties
Methods
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 ( )
frame changed.
Property Descriptions
- String animation
frames resource. If this value changes, the
framecounter is reset.
- bool centered
true, texture will be centered.
- bool flip_h
true, texture is flipped horizontally.
- bool flip_v
true, texture is flipped vertically.
- int frame The displayed animation frame’s index.
- SpriteFrames frames SpriteFrames resource containing the animation(s). Allows you the option to load, edit, clear, make unique and save the states of the SpriteFrames resource.
- Vector2 offset The texture’s drawing offset.
- bool playing
true, the animation is currently playing.
- float speed_scale
The animation speed is multiplied by this value.
Method Descriptions
- play ( String anim=””, bool backwards=false )
anim. If noanimis provided, the current animation is played. Ifbackwardsistrue, the animation will be played in reverse.
- stop ( ) Stops the current animation (does not reset the frame counter).
