var Background = new Phaser.Class({ Extends: Phaser.Scene, initialize: function Background () { Phaser.Scene.call(this, { key: 'background', active: true }); }, preload: function () { this.load.image('face', 'assets/pics/bw-face.png'); }, create: function () { this.face = this.add.image(-10, 300, 'face'); } }); var Demo = new Phaser.Class({ Extends: Phaser.Scene, initialize: function Demo () { Phaser.Scene.call(this, { key: 'demo', active: true }); }, preload: function () { this.load.image('arrow', 'assets/sprites/longarrow.png'); }, create: function () { this.arrow = this.add.image(400, 300, 'arrow').setOrigin(0, 0.5); this.input.once('pointerdown', function () { this.scene.swapPosition('background'); }, this); }, update: function (time, delta) { this.arrow.rotation += 0.01; } }); var config = { type: Phaser.AUTO, width: 800, height: 600, backgroundColor: '#000000', parent: 'phaser-example', scene: [ Background, Demo ] }; var game = new Phaser.Game(config);
Scan to open on your mobile device
var Background = new Phaser.Class({ Extends: Phaser.Scene, initialize: function Background () { Phaser.Scene.call(this, { key: 'background', active: true }); }, preload: function () { this.load.image('face', 'assets/pics/bw-face.png'); }, create: function () { this.face = this.add.image(-10, 300, 'face'); } }); var Demo = new Phaser.Class({ Extends: Phaser.Scene, initialize: function Demo () { Phaser.Scene.call(this, { key: 'demo', active: true }); }, preload: function () { this.load.image('arrow', 'assets/sprites/longarrow.png'); }, create: function () { this.arrow = this.add.image(400, 300, 'arrow').setOrigin(0, 0.5); this.input.once('pointerdown', function () { this.scene.swapPosition('background'); }, this); }, update: function (time, delta) { this.arrow.rotation += 0.01; } }); var config = { type: Phaser.AUTO, width: 800, height: 600, backgroundColor: '#000000', parent: 'phaser-example', scene: [ Background, Demo ] }; var game = new Phaser.Game(config);