Loading your sprite sheet in Phaser and PixiJS
The tool exports a sprite sheet image plus a .json atlas in TexturePacker's "JSON Hash" format, a de facto standard. Here's how to play it in the two most popular JavaScript engines.
What's in the JSON
The atlas lists every frame by name with its x, y, w and h on the sheet. If you used Trim transparent padding, it also includes spriteSourceSize and sourceSize, so the engine can put the trimmed art back at its original position. A meta block records the image file name and sheet size.
Keep the image and JSON in the same folder and don't rename the image without updating meta.image.
Phaser 3
class Game extends Phaser.Scene {
preload() {
// atlas(key, imageURL, jsonURL)
this.load.atlas('hero', 'assets/spritesheet.webp', 'assets/spritesheet.json');
}
create() {
this.anims.create({
key: 'hero-run',
frames: this.anims.generateFrameNames('hero'), // every frame, in order
frameRate: 12,
repeat: -1 // loop forever
});
this.add.sprite(400, 300, 'hero').play('hero-run');
}
}
Set frameRate to the capture FPS you used. For a ping-pong loop without baked frames, add yoyo: true.
PixiJS (v7 and v8)
import { Assets, AnimatedSprite } from 'pixi.js';
const sheet = await Assets.load('assets/spritesheet.json'); // loads the image too
const frames = Object.values(sheet.textures);
const hero = new AnimatedSprite(frames);
hero.animationSpeed = 12 / 60; // capture FPS / display FPS
hero.loop = true;
hero.play();
app.stage.addChild(hero);
Other engines
- Godot: import the sheet as a texture and use an
AnimatedSprite2Dwith SpriteFrames → Add frames from sprite sheet, entering the column and row counts the tool shows under the preview. Or export the ZIP of frames and drag them in. - Unity: set the texture's Sprite Mode to Multiple and slice by cell count in the Sprite Editor, or use a TexturePacker importer that reads the JSON.
- CSS / web: use the GIF, or animate
background-positionacross a single-row strip withsteps().
Troubleshooting
- Black or white box instead of transparency: export as PNG; some older pipelines mishandle WebP alpha.
- Animation jitters: make sure the engine honours the trim offsets, or turn trimming off.
- Texture fails to load on mobile: the sheet is probably over 4096 px. Lower the output scale or FPS.