Create and organize sprite sheets from the frames a game already has: pack separate images into one sheet with a JSON map (trimming empty borders without making frames jump, padding and edge extrusion against bleeding, shared duplicates, power-of-two sizes, pixel-art settings, animations from file names), cut a grid sheet into frames, list what's in a sheet, and draw frames and play animations ...
Download skill (.zip) Files on GitHubSprite sheet generation
Pack frames into a sheet
python3 scripts/pack-sprites.py pack art/hero/ --out assets/sprites/hero --trim --extrude 1
python3 scripts/pack-sprites.py pack art/tiles/ --out assets/sprites/tiles --pixel # pixel art
python3 scripts/pack-sprites.py info assets/sprites/hero.json
Name frames so animations are found: run_0.png, run_1.png... or run/01.png, run/02.png... become animation run.
| Option | Use |
|---|---|
| –trim | cut empty borders (smaller sheet); offsets are kept so frames line up |
| –padding 2 | gap between frames |
| –extrude 1 | repeat edge pixels: stops thin lines from neighbouring frames when scaled |
| –pixel | pixel art: smoothing off, padding and extrude at least 1 |
| –pot | power-of-two size (some WebGL setups need it) |
| –max 2048 | largest sheet; above 2048 can fail on older phones |
One sheet per character, level or screen, not one for the whole game.
Cut a grid sheet
python3 scripts/pack-sprites.py slice downloaded-sheet.png --size 32x32 --margin 0 --spacing 0 --out art/slime/ --name slime
Use it
import { loadAtlas } from "./atlas.js"; // assets/atlas.js
const hero = await loadAtlas("assets/sprites/hero.json");
const run = hero.animation("run", { fps: 12 });
run.update(dt); hero.draw(ctx, run.frame(), player.x, player.y, { anchor: [0.5, 1], flip: player.dir < 0 });
Phaser: this.load.atlas("hero", "hero.png", "hero.json"). PixiJS: Assets.load("hero.json"). Animation states (idle,
run, jump): sprite-animation, with hero.frameNames("run"). Organizing and naming files: game-asset-management. Licenses
of downloaded sheets: game-asset-license-audit.
Pitfalls
Trimming without offsets (characters jitter), no padding (bleeding lines), smoothing on pixel art, giant sheets for phones, and frame names without numbers (no animations found).