Sprite Sheet & Timeline Animation (`engine.Animation`)

Manage 2D sprite sheets, define multi-state character timelines, interpolate keyframe durations, and edit animations visually using the built-in PyLua Animator Editor.

1. Script Animation API

character_animation.lua
import engine

-- Load sprite atlas with 64x64 frame grid:
heroAnim = engine.Animation.load("assets/hero_sheet.png", 64, 64)

-- Define keyframe sequence with duration in seconds:
heroAnim:createSequence("run", {
    { frame = 0, duration = 0.1 },
    { frame = 1, duration = 0.1 },
    { frame = 2, duration = 0.1 },
    { frame = 3, duration = 0.1 }
})

heroAnim:play("run")

-- In main update / draw loop:
function onUpdate(dt) {
    heroAnim:update(dt)
}

function onDraw() {
    heroAnim:draw(player.x, player.y, 2.0) -- 2x scale multiplier
}

2. Integrated Animation Editor PRO

PyLua includes a standalone visual keyframe editor built directly into the executable. Launch it via terminal:

terminal
pylua -engine animation
Keybinding Editor Action
TAB Cycle through active animation sequences (e.g. Idle, Run, Jump, Attack).
N Create a new animation sequence.
SPACE Play / Pause animation preview playback.
A Insert new keyframe into active sequence.
DELETE Delete the currently selected keyframe.
← / → Change frame index in sprite atlas.
+ / - Increase or decrease keyframe duration by 0.05s.