var config = { type: Phaser.AUTO, width: window.innerWidth, height: window.innerHeight, backgroundColor: '#0055aa', parent: 'phaser-example', scene: Controller }; var game = new Phaser.Game(config); window.addEventListener('resize', function (event) { game.resize(window.innerWidth, window.innerHeight); }, false);
class Controller extends Phaser.Scene { constructor () { super(); } resize (width, height) { if (width === undefined) { width = this.game.config.width; } if (height === undefined) { height = this.game.config.height; } this.cameras.resize(width, height); } }
Scan to open on your mobile device
var config = { type: Phaser.AUTO, width: window.innerWidth, height: window.innerHeight, backgroundColor: '#0055aa', parent: 'phaser-example', scene: Controller }; var game = new Phaser.Game(config); window.addEventListener('resize', function (event) { game.resize(window.innerWidth, window.innerHeight); }, false);
class Controller extends Phaser.Scene { constructor () { super(); } resize (width, height) { if (width === undefined) { width = this.game.config.width; } if (height === undefined) { height = this.game.config.height; } this.cameras.resize(width, height); } }