Scene From Instance

Demonstrates how to define a Scene by creating a new Phaser.Scene instance and manually assigning its lifecycle functions such as preload and create.

Scene From Instance, running
800 × 600
GitHub
const demo = new Phaser.Scene('Demo');

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

demo.create = function ()
{
    this.add.image(400, 300, 'face');
}

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

const game = new Phaser.Game(config);

More in Scenes52 examples