Build games as easily as you play them — join the Phaser Beam waitlist for Early Access.
class Example extends Phaser.Scene { constructor () { super(); } preload () { this.load.setBaseURL('https://cdn.phaserfiles.com/v385'); this.load.image('robota', 'assets/pics/robota-uxo-by-made-of-bomb.jpg'); } create () { const image = this.add.image(900, 300, 'robota'); this.tweens.add({ targets: image, x: 100, ease: 'Sine.easeInOut', yoyo: true, repeat: -1, duration: 3000 }); this.cameras.main.once('camerafadeincomplete', function (camera) { camera.fadeOut(6000); }); this.cameras.main.fadeIn(6000); } } const config = { type: Phaser.AUTO, parent: 'phaser-example', width: 800, height: 600, scene: Example }; const game = new Phaser.Game(config);
class Example extends Phaser.Scene
{
constructor ()
{
super();
}
preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v385');
this.load.image('robota', 'assets/pics/robota-uxo-by-made-of-bomb.jpg');
}
create ()
{
const image = this.add.image(900, 300, 'robota');
this.tweens.add({
targets: image,
x: 100,
ease: 'Sine.easeInOut',
yoyo: true,
repeat: -1,
duration: 3000
});
this.cameras.main.once('camerafadeincomplete', function (camera) {
camera.fadeOut(6000);
});
this.cameras.main.fadeIn(6000);
}
}
const config = {
type: Phaser.AUTO,
parent: 'phaser-example',
width: 800,
height: 600,
scene: Example
};
const game = new Phaser.Game(config);