AnimationController
A sprite animation manager and controller.
Constructor
AnimationController()Load animations with load_sprite_sheet before using.
Properties
| Name | Description | Type |
|---|---|---|
current_animation_name | The current animation's name | str |
clip | The source rectangle (clip) for the current animation frame | Rect |
texture | The sprite sheet texture used by this animation controller | Texture |
playback_speed | The playback speed multiplier | float |
frame_index | The current frame index of the animation | int |
progress | The progress through the current animation as a value between 0.0 and 1.0 | float |
looping | Whether the animation should loop after playing | bool |
Methods
Load Sprite Sheet
load_sprite_sheet(
file_path: str,
frame_size: Vec2,
strips: list[SheetStrip]
) → NoneLoad animation frames from a sprite sheet. Strips are read horizontally from left to right, top to bottom, as provided in the strips list.
Parameters
file_path: The path to the sprite sheet image file.frame_size: The size of each frame in the sprite sheet.strips: A list of sheet strips to load from the sprite sheet.
Set
set(name: str) → NoneSet the current animation by name without affecting playback state.
Parameters
name: The name of the animation to set as current.
Play
play(name: str) → NonePlay an animation from the beginning by name.
Parameters
name: The name of the animation to play.
Play From
play_from(frame_index: int) → NonePlay an animation from a specific frame.
Parameters
frame_index: The index of the frame to start playing from.
Is Finished
is_finished() → boolCheck if the current animation has finished a loop since the last frame update.
Returns
bool : True if the animation is finished, otherwise False.
Rewind
rewind() → NoneRewind the current animation to the first frame.
Pause
pause() → NonePause the current animation.
Resume
resume() → NoneResume the current animation.