Home › Use cases › Phaser 3 sprite sheet tutorial · Updated Nov 11, 2026
Phaser 3.80+ Guide · Copy-Paste TypeScript/JS + Live Demo

Import a 4-direction sprite sheet in Phaser 3.

Phaser 3 is the fastest engine for browser RPGs and vibe-coded web games — if you configure pixel filtering, frame indices, and foot-level Arcade Physics hitboxes right. Test our live 4×4 sheet below with WASD/arrows, then copy the exact loader into your scene.

Make a sprite — $5Download free starter ZIP
No account · 96px + 48px + RPG Maker $character.png · 3 free retries + money-back QA guarantee

Live 4-Direction Walk Sandbox (/samples/sheet-96.png)

Click a direction below (or press WASD / Arrow keys while focused) to inspect how rows 0..3, idle column 0, foot baseline y=90, and the green Arcade Physics foot hitbox behave at 2× zoom:

Frame: down_01 (row 0, col 0)
Source rect: x=0, y=0, w=96, h=96
Foot baseline: y = 90 (pink line)
Arcade body: setSize(48, 46); setOffset(24, 44) (green box)

Option A (Recommended): Load atlas_96.json with this.load.atlas

Every schema-v2 PixelForge ZIP (including starter-pack.zip) ships pre-built Phaser 3 / TexturePacker JSON Hash sidecars at processed/phaser/atlas_96.json and atlas_48.json. Named frames (down_01..04, left_01..04, right_01..04, up_01..04) eliminate off-by-one frame index bugs:

import Phaser from 'phaser';

export class WorldScene extends Phaser.Scene {
  private player!: Phaser.Types.Physics.Arcade.SpriteWithDynamicBody;
  private cursors!: Phaser.Types.Input.Keyboard.CursorKeys;
  private facing: 'down' | 'left' | 'right' | 'up' = 'down';

  preload() {
    this.load.atlas(
      'hero',
      '/assets/player/processed/sprite-sheet-96-transparent.png',
      '/assets/player/processed/phaser/atlas_96.json'
    );
  }

  create() {
    for (const dir of ['down', 'left', 'right', 'up'] as const) {
      this.anims.create({
        key: `walk-${dir}`,
        frames: this.anims.generateFrameNames('hero', {
          prefix: `${dir}_`,
          start: 1,
          end: 4,
          zeroPad: 2,
        }),
        frameRate: 1000 / 135, // ~7.41 FPS
        repeat: -1,
      });
    }

    this.player = this.physics.add.sprite(320, 240, 'hero', 'down_01');
    // Lock collision box to the lower body / boots (foot_baseline_y = 90)
    this.player.body.setSize(48, 46).setOffset(24, 44);
    this.cursors = this.input.keyboard!.createCursorKeys();
  }

  update() {
    const speed = 150;
    const body = this.player.body;
    body.setVelocity(0);

    if (this.cursors.left.isDown) { body.setVelocityX(-speed); this.facing = 'left'; }
    else if (this.cursors.right.isDown) { body.setVelocityX(speed); this.facing = 'right'; }
    if (this.cursors.up.isDown) { body.setVelocityY(-speed); this.facing = 'up'; }
    else if (this.cursors.down.isDown) { body.setVelocityY(speed); this.facing = 'down'; }

    body.velocity.normalize().scale(speed);

    if (body.velocity.lengthSq() > 0) {
      this.player.anims.play(`walk-${this.facing}`, true);
    } else {
      this.player.anims.stop();
      this.player.setFrame(`${this.facing}_01`); // idle_column = 0
    }
    // Top-down Y-sort by boots
    this.player.setDepth(this.player.y);
  }
}

Option B: Load any 4×4 PNG directly with this.load.spritesheet

If you only want a single PNG file in public/assets/, slice by frameWidth: 96, frameHeight: 96 (or 48, 48 on the 48px sheet):

// Game config: always enable pixelArt + roundPixels!
const config: Phaser.Types.Core.GameConfig = {
  type: Phaser.AUTO,
  width: 640,
  height: 360,
  pixelArt: true,
  roundPixels: true,
  physics: { default: 'arcade', arcade: { debug: false } },
  scene: [WorldScene],
};

// Inside preload():
this.load.spritesheet('hero', '/assets/sprite-sheet-96-transparent.png', {
  frameWidth: 96,
  frameHeight: 96,
});
// Row indices: down = 0..3, left = 4..7, right = 8..11, up = 12..15 (idle = 0, 4, 8, 12)

3 Phaser pixel-art gotchas (and instant fixes)

Frequently asked questions

Should I use load.atlas or load.spritesheet in Phaser 3?

Both work cleanly with PixelForge sheets because every cell is an exact 96×96 (or 48×48) grid. this.load.atlas with processed/phaser/atlas_96.json is slightly nicer for readability and AI coding agents because frame names like down_01 are self-documenting instead of numeric indices 0..15.

Why is my pixel art blurry in Phaser 3?

Phaser defaults to linear texture interpolation unless you pass pixelArt: true at the top level of your Phaser.Game config object. Setting pixelArt: true switches all WebGL and Canvas textures to crisp nearest-neighbor rendering.

Where can I get a free Phaser 3 4-direction sprite sheet to test this code?

Download /samples/starter-pack.zip ($0, CC0 commercial license) — it contains the exact sprite-sheet-96-transparent.png, sprite-sheet-48-transparent.png, atlas_96.json, and atlas_48.json running in the sandbox above.

Put anyone into your game.

$5 · one photo · 4-direction walk pack (96px, 48px, RPG Maker & Phaser atlas) · 3 free retries · no subscription

Make a sprite — $5