gfx.sprite.sheet

gfx.sprite

sheet(src, opts) -> sheet, err

Create a sprite sheet (atlas) over a source image

Frames come from a tile grid or from explicit rects.

opts fielddescription
tile_w, tile_htile size; required without frames
marginborder around the grid, default 0
spacinggap between tiles, default 0
framesan array of {x, y, w, h} rects, a map of name -> {x, y, w, h}, or both

Grid frames count from 1, left to right, then top to bottom.

sheet:frame(index_or_name) returns the frame's sprite, or nil. sheet:nframes() returns the count of numbered frames.