sprite — Luau Binding
require("sprite"): create and control movable image objects on either graphics backend. Each sprite is a stage target, so the rest of the family moves it. The programmatic surface of the sprite system. Every function is[antos].
Status: design. Not built yet.
local sprite = require("sprite")
| Call | Returns | Does |
|---|---|---|
sprite.new(image, opts?) |
spr |
create a sprite (a target). opts = { target = "auto", x, y, z, frames, size } — target is "hardware" / "top" / "bottom" / "auto", the plane it draws to |
spr:image(img) / spr:frame(n) |
ok |
set the picture, or the current frame |
spr:animate(seq, fps, loop?) |
ok |
play a frame sequence on the tick |
spr:flip(fx, fy) / spr:palette(p) / spr:z(n) |
ok |
mirror, recolour, reorder |
spr:parent(other?) |
parent |
parent spr to other so its position / scale / rotation are relative — move, scale, or rotate the parent and spr follows; no arg detaches it to the top level |
spr:children() |
list | the sprites parented to spr |
spr:show() / spr:hide() / spr:free() |
ok |
visibility, and release (removes it from the family) |
local sprite = require("sprite")
local hero = sprite.new("hero.png", { frames = 8, target = "top" }) -- overlay the FPGA guest
hero:animate({1,2,3,4}, 12, true) -- walk cycle
motion.play(hero, "FD 200") -- ...and it's a target, so motion moves it
Where to go next
- The sprite model and the two backends → sprite · the backends → software chipset / FireStorm
- What moves it → motion · pooling → spawn