Animated Sprite
animated_sprite = Components::AnimatedSprite.new(
Assets.texture("spritesheet.png"), # Spritesheet
{128, 128}, # 128x128 texture size
# idle walk and run are three animations based on the same 4 frames, but in varying speed
# jump is 8 frames long and runs at 16 FPS
# the spritesheet is layed out like this:
#
# AAAA####
# BBBBBBBB
#
# A = idle/walk/run frames
# B = jump frames
{
"idle" => {0, 4, 4},
"walk" => {0, 4, 8},
"run" => {0, 4, 16},
"jump" => {8, 8, 16}
}
)Last updated