Build games as easily as you play them — join the Phaser Beam waitlist for Early Access.
class Example extends Phaser.Scene { constructor() { super({ key: 'test', active: false }); } init (data) { this.png = data.image; } preload () { this.load.setBaseURL('https://cdn.phaserfiles.com/v385'); this.load.image('mech', 'assets/pics/' + this.png); } create (data) { this.add.image(data.x, data.y, 'mech'); } } const config = { type: Phaser.AUTO, parent: 'phaser-example', width: 800, height: 600, scene: Example }; const game = new Phaser.Game(config); game.scene.start('test', { image: 'titan-mech.png', x: 400, y: 300 });
class Example extends Phaser.Scene
{
constructor()
{
super({ key: 'test', active: false });
}
init (data)
{
this.png = data.image;
}
preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v385');
this.load.image('mech', 'assets/pics/' + this.png);
}
create (data)
{
this.add.image(data.x, data.y, 'mech');
}
}
const config = {
type: Phaser.AUTO,
parent: 'phaser-example',
width: 800,
height: 600,
scene: Example
};
const game = new Phaser.Game(config);
game.scene.start('test', { image: 'titan-mech.png', x: 400, y: 300 });