class

PointClickEngine::Characters::AnimationController

Inherits Reference < Object

Manages animation playback and state for character sprites

The AnimationController handles all aspects of character animation including:

  • Animation definition and storage
  • Playback control and state management
  • Mood-based animation selection
  • Frame timing and looping
  • 8-directional animations
  • Idle variations
  • Animation priorities and interruption

Constants

IDLE_TRIGGER_TIME = 8.0_f32

Constants

TURN_ANIMATION_SPEED = 2.0_f32

Constructors

new(sprite : Graphics::AnimatedSprite | Nil = nil)
Source

Instance methods

add_animation(name : String, start_frame : Int32, frame_count : Int32, frame_speed : Float32 = Core::GameConstants::DEFAULT_ANIMATION_SPEED, loop : Bool = true, priority : Int32 = 0, interruptible : Bool = true, auto_return_to_idle : Bool = true, sound_effect : String | Nil = nil)

Defines a named animation for the character

Source
add_directional_animation(base_name : String, start_frame : Int32, frames_per_direction : Int32, frame_speed : Float32 = 0.1)

Add directional animations (8 directions for one animation type)

Source
add_idle_variation(name : String, start_frame : Int32, frame_count : Int32, frame_speed : Float32 = 0.2)

Add idle variations

Source
animation_names

Gets list of all available animation names

Source
animations

Collection of defined animations by name

Source
animations=(animations : Hash(String, AnimationData))

Collection of defined animations by name

Source
clear_animations

Clears all animations

Source
current_animation

Name of the currently playing animation

Source
current_animation=(current_animation : String)

Name of the currently playing animation

Source
current_animation_data

Gets current animation data

Source
current_direction

Current 8-directional facing for enhanced animations

Source
current_direction=(current_direction : Direction8)

Current 8-directional facing for enhanced animations

Source
direction

Current facing direction for directional animations (2D)

Source
direction=(direction : Direction)

Current facing direction for directional animations (2D)

Source
get_animation(name : String) : AnimationData | Nil

Gets animation data for a specific animation

Source
has_animation?(name : String) : Bool

Checks if an animation exists

Source
idle_timer

Idle animation system

Source
idle_timer=(idle_timer : Float32)

Idle animation system

Source
idle_variations
Source
idle_variations=(idle_variations : Array(String))
Source
last_direction
Source
last_direction=(last_direction : Direction8)
Source
mood

Current character mood for mood-based animations

Source
mood=(mood : CharacterMood)

Current character mood for mood-based animations

Source
on_animation_complete

Callback for when animations complete

Source
on_animation_complete=(on_animation_complete : Proc(String, Nil) | Nil)

Callback for when animations complete

Source
pause

Pauses current animation (preserves frame timer)

Source
play_animation(name : String, force_restart : Bool = true) : Bool

Plays a named animation with priority checking

Source
playing?

Checks if any animation is currently playing

Source
remove_animation(name : String)

Removes an animation

Source
resume

Resumes paused animation (without resetting frame timer)

Source
set_direction(new_direction : Direction)

Sets character direction and updates animations

Source
set_mood(new_mood : CharacterMood)

Sets character mood and updates animations

Source
set_state(new_state : CharacterState)

Sets character state and updates animations

Source
sprite

Reference to the sprite being animated

Source
sprite=(sprite : Graphics::AnimatedSprite)

Sets the sprite to animate

Source
sprite=(sprite : Graphics::AnimatedSprite | Nil)

Reference to the sprite being animated

Source
state

Current character state for state-based animation selection

Source
state=(state : CharacterState)

Current character state for state-based animation selection

Source
stop

Stops current animation

Source
turn_threshold

Turn animation threshold in degrees

Source
turn_threshold=(turn_threshold : Float32)

Turn animation threshold in degrees

Source
update(dt : Float32, sprite : Graphics::AnimatedSprite | Nil)

Update with sprite reference (for compatibility)

Source
update(dt : Float32)

Updates animation playback based on delta time

Source
update_directional_animation(state : AnimationState, direction : Direction8, force : Bool = false)

Update direction-based animation (8-directional)

Source
update_directional_animation

Updates animation based on movement direction

Source
update_idle(dt : Float32)

Update idle system

Source
update_mood_animation

Updates character animation based on current mood

Source
update_state_animation

Updates animation based on character state

Source