Jump to content

Finding the maximum browser height, width (Scaling Manager)


JSON
 Share

Recommended Posts

Hey, so I almost finished my game, and I'm encountering a problem in scaling. I first used Window.Innerheight and Window.innerwidth for the game size

The problem is that when I start the game on browser that is not maximized, and then maximize it after loading the game, the sprites scale up too big. 

I used 

game.scale.fullScreenScaleMode = Phaser.ScaleManager.SHOW_ALL;
game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
game.scale.refresh();

So I decided to just load the game in maximized innerheight and innerwidth. But I do not know how to do that or if it's possible. Is there any way to find the window.innerheight and window.innerwidth when the browser is MAXIMIZED or FULLSCREEN?

 

THANKS

Link to comment
Share on other sites

For now, I'm using window.availheight and window.availwidth, which is always constant and does not change when the browser size changes. It's not 100% on the point because it does not take into consideration of taskbar size and stuff. So I think I need to offset the position of the sprites?

Please let me know if there is any better solution 

Capture.JPG

Link to comment
Share on other sites

On 6/5/2017 at 4:57 PM, JSON said:

Hey, so I almost finished my game, and I'm encountering a problem in scaling. I first used Window.Innerheight and Window.innerwidth for the game size

The problem is that when I start the game on browser that is not maximized, and then maximize it after loading the game, the sprites scale up too big. 

 

Like @Abhishek Singhal said, you definitely can use window.innerWidth and window.innerHeight for your scaling calculations, just make sure to add an event listener to window.onresize and recalculate things when the browser is resized.

Scaling definitely isn't a trivial problem to solve, though, so I totally feel your pain in trying to get things perfect. Good luck!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...