Loading a Base64 Texture Atlas

Demonstrates how to load a texture atlas by passing Base64 encoded strings for both the image and the JSON data, instead of loading external files.

Loading a Base64 Texture Atlas, running
800 × 600
GitHub
// #module
import { spookyJSON, spookyPNG } from '../../../assets/base64/spooky-atlas.js';

class Example extends Phaser.Scene
{
    preload ()
    {
        this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
        this.load.atlas('spooky', spookyPNG, spookyJSON);
    }

    create ()
    {
        const atlasTexture = this.textures.get('spooky');

        const frames = atlasTexture.getFrameNames();

        for (let i = 0; i < frames.length; i++)
        {
            const x = Phaser.Math.Between(100, 700);
            const y = Phaser.Math.Between(100, 500);

            this.add.image(x, y, 'spooky', frames[i]);
        }
    }
}

const config = {
    scale: { mode: Phaser.Scale.FIT },
    type: Phaser.AUTO,
    width: 800,
    height: 600,
    parent: 'game-container',
    scene: Example
};

const game = new Phaser.Game(config);

More in Base644 examples