garethquirke Posted April 20, 2017 Share Posted April 20, 2017 My game does not scale correctly when the browser loads the game while the window size is made smaller. Another scenario is while in game state, the game will resize correctly, If I try to make the window bigger once again the game will be made out of scale and not usable really. this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; Link to comment Share on other sites More sharing options...
scheffgames Posted April 20, 2017 Share Posted April 20, 2017 bootGame.prototype.create = function(){ console.log("Booting game"); if (game.device.desktop) { game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; game.scale.setMinMax(480,320,720,480) game.scale.pageAlignHorizontally = true; game.scale.pageAlignVertically = true; } else { game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; game.scale.setMinMax(480,320); game.scale.pageAlignHorizontally = true; game.scale.pageAlignVertically = true; game.scale.forceOrientation(true,false); } game.scale.refresh(); game.stage.backgroundColor = "#007f5f"; } The above piece of code should work - best to put it in boot state. Modify scale min max to adjust your game needs - in the example above I say - the game should be scaled to a minimum of 480x320 but if more space it's available scale it to max 720x480. It also places the game nicely in the center. And finally forceOrientation(true,false) sets the game in landscape mode when on mobile (if you want it in portrait mode use forceOrientation(false,true) ) garethquirke 1 Link to comment Share on other sites More sharing options...
garethquirke Posted April 20, 2017 Author Share Posted April 20, 2017 I have a unorthodox style of my game states using the let keyword for each state. So I'll try this snippet in the boot stage of my game state, thanks for your help scheffgames 1 Link to comment Share on other sites More sharing options...
samme Posted April 21, 2017 Share Posted April 21, 2017 See the guidelines in https://photonstorm.github.io/phaser-ce/Phaser.ScaleManager.html Link to comment Share on other sites More sharing options...
silvanet Posted May 25, 2019 Share Posted May 25, 2019 On 4/21/2017 at 12:42 AM, samme said: See the guidelines in https://photonstorm.github.io/phaser-ce/Phaser.ScaleManager.html I'm following a course, using CE version 2.10. I used it on a prior project (same version) in which init: function() { game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; game.scale.pageAlignHorizontally = true; game.scale.pageAlignVertically = true; }, worked perfectly to align and scale the background, but for some reason that same code is not working on the new project. We're referring to the phaser.min.js in a script section at the bottom of the index.html file as before. I'm literally stuck. I know I can use coordinates, but that is a pain in the butt. It seems to be roughly scaling, but with the background image definitely not centered either horizontally or vertically. I'm editing with Visual Studio Code version 1.34 stable. BTW, can you suggest a nice bracket coloring extension that works nicely with Phaser? Link to comment Share on other sites More sharing options...
Recommended Posts