class

PointClickEngine::Graphics::Sprites::AnimatedSprite

Inherits PointClickEngine::Graphics::Sprites::Sprite < Reference < Object

Animated sprite with frame-based animation support

AnimatedSprite extends the base Sprite class to support sprite sheet animations with configurable timing, looping, and playback control.

Example

# Create an 8-frame walk animation
sprite = AnimatedSprite.new("assets/character_walk.png", 64, 64, 8)
sprite.frame_duration = 0.1 # 10 FPS
sprite.play

# One-shot animation
explosion = AnimatedSprite.new("explosion.png", 128, 128, 12)
explosion.loop = false
explosion.on_complete do
  scene.remove_object(explosion)
end

Constructors

new(x : Float32, y : Float32, texture_path : String, frame_width : Int32, frame_height : Int32, frame_count : Int32)

Initialize at position

Source
new(texture_path : String, frame_width : Int32, frame_height : Int32, frame_count : Int32)

Initialize with sprite sheet

Source

Instance methods

center_origin

Override center_origin to use frame dimensions instead of texture dimensions

Source
clone

Clone the animated sprite

Source
current_frame
Source
current_frame=(current_frame : Int32)
Source
finished?

Check if animation finished (for non-looping)

Source
frame_count
Source
frame_count=(frame_count : Int32)
Source
frame_duration
Source
frame_duration=(frame_duration : Float32)
Source
frame_height
Source
frame_height=(frame_height : Int32)
Source
frame_speed
Source
frame_speed=(value : Float32)

Alias for frame_duration for compatibility

Source
frame_width

Animation properties

Source
frame_width=(frame_width : Int32)

Animation properties

Source
loop
Source
loop=(loop : Bool)
Source
on_frame_change

Set callback for frame changes

Source
play

Start playing animation

Source
play_once

Play animation once

Source
playing
Source
playing=(playing : Bool)
Source
progress

Get animation progress (0.0 to 1.0)

Source
reset

Reset animation to first frame

Source
set_frame(frame : Int32)

Set specific frame

Source
stop

Stop animation

Source
total_duration

Get total animation duration

Source
update(dt : Float32)

Update animation

Source