Skip to content

LÖVE exporter

Output

Packrat writes one Lua descriptor and one image per atlas page:

text
atlas.lua
atlas.png

The Lua table contains the atlas page path, frame rectangles, original frame size, trim offsets, animation indices, and helper methods for loading and drawing.

Integrate

Keep the files under the LÖVE project root and require the descriptor:

lua
local atlas = require("atlas")
atlas:load()
atlas:draw("player_0001", 320, 180)

Use atlas:frame(name) for raw metadata or atlas:add(batch, name, ...) for a SpriteBatch-style batch. The generated helpers select the correct atlas page and apply trim offsets.

Minimal program

Put atlas.lua and atlas.png in the LÖVE project root. Replace player_0001 with a frame name that exists in your atlas:

lua
local atlas

function love.load()
    atlas = require("atlas")
    atlas:load()
end

function love.draw()
    local frame = atlas:frame("player_0001")
    atlas:draw("player_0001", 400, 300, 0, 2, 2,
        frame.source_width / 2, frame.source_height / 2)
end

The generated draw helper loads the atlas page and applies the frame's trim offset.

Packrat documentation