Scene Injection Map

Demonstrates how to remap standard Scene systems like 'add' and 'load' to custom property names using the scene configuration map.

Scene Injection Map, running
800 × 600
GitHub
class Example extends Phaser.Scene
{
    constructor() {
        super({
            key: 'Example',
            map: {
                add: 'makeStuff',
                load: 'loader'
            }
        });
    }

    preload ()
    {
        this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
        this.loader.image('face', 'assets/pics/bw-face.png');
    }

    create ()
    {
        this.makeStuff.image(400, 300, 'face');
        console.log(this);
    }
}

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 Scenes52 examples