Scene From Object
Demonstrates how to define a Scene using a standard JavaScript object within the Game Configuration, mapping lifecycle functions like preload and create.
800 × 600
function preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
this.load.image('face', 'assets/pics/bw-face.png');
}
function create ()
{
this.add.image(400, 300, 'face');
}
const config = {
scale: { mode: Phaser.Scale.FIT },
type: Phaser.CANVAS,
parent: 'game-container',
width: 800,
height: 600,
scene: {
preload: preload,
create: create
}
};
const game = new Phaser.Game(config);