Scene From Function
Learn how to define a Scene using a standard JavaScript constructor function and prototype pattern.
800 × 600
const MyGame = {};
MyGame.Boot = function ()
{
this.face = null;
};
MyGame.Boot.prototype.constructor = MyGame.Boot;
MyGame.Boot.prototype = {
preload: function ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
this.load.image('face', 'assets/pics/bw-face.png');
},
create: function ()
{
this.face = this.add.image(400, 300, 'face');
}
};
const config = {
scale: { mode: Phaser.Scale.FIT },
type: Phaser.CANVAS,
parent: 'game-container',
width: 800,
height: 600,
scene: MyGame.Boot
};
const game = new Phaser.Game(config);