Scene From ES6 Class
Demonstrates how to define a Phaser Scene using ES6 class syntax, including the constructor and standard lifecycle methods.
800 × 600
class MyScene extends Phaser.Scene {
constructor (config)
{
super(config);
}
preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
this.load.image('face', 'assets/pics/bw-face.png');
}
create ()
{
this.face = this.add.image(400, 300, 'face');
}
}
const config = {
scale: { mode: Phaser.Scale.FIT },
type: Phaser.WEBGL,
width: 800,
height: 600,
backgroundColor: '#000000',
parent: 'game-container',
scene: MyScene
};
const game = new Phaser.Game(config);