AnimationController

An sprite animation manager and controller.

  • AnimationController()

Properties


NameDescriptionType
current_animation_nameThe current animation's namestr
current_frameThe current animation's frameFrame
playback_speedThe playback speed multiplierfloat

Methods


Load Sprite Sheet

load_sprite_sheet(name: str, file_path: str, frame_size: Vec2, fps: int) None

Load animation frames from a sprite sheet image.

Parameters

  • name : The name to assign to the loaded animation.
  • file_path : The path to the sprite sheet image file.
  • frame_size : The size of each frame in the sprite sheet.
  • fps : The frames per second for the animation playback.

Load Folder

load_folder(name: str, dir_path: str, fps: int) None

Load animation frames from a folder.

Parameters

  • name : The name to assign to the loaded animation.
  • dir_path : The path to the folder containing animation frames.
  • fps : The frames per second for the animation playback.

Remove

remove(name: str) None

Remove a loaded animation by name.

Parameters

  • name : The name of the animation to remove.

Note:

If the removed animation is currently active, the controller will be left without a current animation.

Set

set(name: str, rewind: bool = False) None

Set the current animation by name.

Parameters

  • name : The name of the animation to set as current.
  • rewind : Whether to rewind the animation to the first frame.

Is Finished

is_finished() bool

Check 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() None

Rewind the current animation to the first frame.

Pause

pause() None

Pause the current animation.

Resume

resume() None

Resume the current animation.