Duangduean Studios
Practical guides

How to pack PNG animation frames into a sprite sheet

Try four sample slime frames, export a transparent PNG and JSON, and understand the frame coordinates before using them in a game.

By Duangduean Studios · 5 min read

Start with a four-frame experiment

A sprite sheet stores several images in one texture. The frame coordinates tell your game which rectangle to draw. This walkthrough uses four original 32 × 32 pixel slime frames generated by our tool in your browser. You can practise without downloading art or uploading a file.

Open the sprite sheet packer and select “Try slime example”. It replaces the current selection, so export any work you want to keep first. The tool starts with four columns and two pixels of padding per side.

Understand the numbers

Each 32 × 32 frame sits in a 36 × 36 cell: 32 pixels of art plus two pixels on each side. Four columns make a 144 × 36 sheet. Change Columns to 2 and the same frames form a 72 × 72 sheet. Padding here is transparent space; it does not copy or extrude edge pixels.

With four columns and padding of 2, the first frame starts at x = 2, y = 2. The second begins at x = 38, y = 2. Each frame still has w = 32 and h = 32. These positions are measured from the top-left of the exported sheet.

Export the image and its map

  1. Download PNG to save sprite-sheet.png. The transparent background stays transparent.
  2. Choose JSON for Phaser / PixiJS to save sprite-sheet.json. Keep it beside the image.
  3. Look at the JSON frames array. Each entry has a name, x, y, w and h. Check that its size matches your PNG.
  4. Try drawing the first frame using the canvas example below. Set the destination size to 128 × 128 to inspect the pixels.
// image is a loaded sprite-sheet.png; map is the exported JSON.
const frame = map.frames[0];
ctx.imageSmoothingEnabled = false;
ctx.drawImage(image, frame.x, frame.y, frame.w, frame.h,
  0, 0, 128, 128);

Bring your own frames

Use equally sized transparent PNGs for a predictable animation. Select them in the intended order and check the preview: this packer preserves the file-list order, rather than sorting names or finding animation sequences. JPEG and WebP also work, but JPEG cannot preserve transparency.

This is a grid packer, not a tightly packed or rotating texture-atlas exporter. Its JSON is a simple coordinate map, not a promised drop-in format for any particular engine. Use the rectangles in your own loader, or translate them to your engine’s expected format.

Check before shipping

  1. Confirm the PNG dimensions and frame count after changing columns or padding.
  2. Preview every frame against both light and dark backgrounds.
  3. Use nearest-neighbour filtering when you want crisp pixel art.
  4. Test the animation in your actual game; the packer does not set playback speed or create in-between frames.
How to pack PNG animation frames into a sprite sheet