AnimatedSprite¶
Inherits: Node2D < CanvasItem < Node < Object
Category: Core
Brief Description¶
Sprite node that can use multiple textures for animation.
Properties¶
String | animation |
bool | centered |
bool | flip_h |
bool | flip_v |
int | frame |
SpriteFrames | frames |
Vector2 | offset |
bool | playing |
float | speed_scale |
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¶
- String animation
Setter | set_animation(value) |
Getter | get_animation() |
The current animation from the frames
resource. If this value changes, the frame
counter is reset.
- bool centered
Setter | set_centered(value) |
Getter | is_centered() |
If true
, texture will be centered. Default value: true
.
- bool flip_h
Setter | set_flip_h(value) |
Getter | is_flipped_h() |
If true
, texture is flipped horizontally. Default value: false
.
- bool flip_v
Setter | set_flip_v(value) |
Getter | is_flipped_v() |
If true
, texture is flipped vertically. Default value: false
.
- int frame
Setter | set_frame(value) |
Getter | get_frame() |
The displayed animation frame’s index.
- SpriteFrames frames
Setter | set_sprite_frames(value) |
Getter | get_sprite_frames() |
The SpriteFrames resource containing the animation(s).
- Vector2 offset
Setter | set_offset(value) |
Getter | get_offset() |
The texture’s drawing offset.
- bool playing
If true
, the animation is currently playing.
- float speed_scale
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.
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).