Appearance
LÖVE
Packrat writes one Lua module for all pages. The module loads the images, creates quads, and applies trim offsets when drawing. Keep it with the page images under the game root.
lua
local atlas = require("atlas")
local run
function love.load()
atlas:set_filter("nearest", "nearest")
atlas:load()
run = atlas:find_animation("run_side")
end
function love.draw()
atlas:draw(run.frames[1], 400, 300, 0, 2, 2)
end
function love.quit() atlas:unload() endAdvance the frame index in love.update(dt) to animate.
| Method | Use |
|---|---|
load() / unload() | Load or release images and quads |
set_filter(min, mag) | Set image filtering |
frame(name, index) | Find a frame by key or base name; an omitted or negative index selects the first match |
find_animation(name) | Return frames in order, or nil if the animation is missing |
draw(frame, x, y, rotation, sx, sy) | Draw a frame or key |
add(batch, frame, x, y, rotation, sx, sy) | Add to a SpriteBatch |
If omitted, position and rotation default to 0, and scale defaults to 1. sy defaults to sx. The atlas.definition table contains the format version (2), pages, frames, and animations. Page numbers start at 1. source_x and source_y are trim offsets measured from the top-left of the original frame.
The draw position is the center of the original, untrimmed frame. Rotation is measured in radians.
See Sources and outputs for frame names, trimming, and effect maps.