0
votes

I have a menu that links to basically two different games. One is a portrait game essentially, tall and skinny, while the other is short and long. I want my game size to change based on which game I enter, but I can't change it. The best I've found by browsing the web is to use: this.scale.setGameSize(width, height);

The problem is, I get a message that setGameSize is not a function. Anybody have any ideas?

2

2 Answers

1
votes

If you have two different games then you would have two different game objects. The size is specified in the constructor for the game object.

var portrait_game  = new Phaser.Game(600, 1200, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update });   
var landscape_game = new Phaser.Game(1200, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update });
0
votes

you need to write some code what "this" refer to you can use

var game = new Phaser.Game(width ,height,Phaser.AUTO,"gameContainer")
game.scale.setGameSize(width, height);

but make sure to change game.scale.forcePortrait , game.scale.forceLandscape