Exact fit with variable height

Recommended Posts

Hi everyone,

I really want to use whole browser window but keep my game correctly scaled.


Is there any easy way how to make game height variable with fixed width using current scale modes? I've tried several approaches without any luck.


Same resize method but horizontal (which doesn't really matter) can be seen for example on




Thanks a lot!



Share this post

Link to post
Share on other sites

Hi JoseDu,


Here's a +1 for your inquiry, since I need the same behavior for one of my games (I'd like to make full use of the screen without distorting anything, as well), but from all I can see there is no such scale mode that handles what you ask for all by itself.


It'd be great, if that were possible from somewhere within Phaser since it provides all those handy utilities for detecting devices, OSs and stuff. A scale mode that would take care of this all by itself would be brilliant, but I'd already be happy, if I could simply adjust canvas/game size after setting stage scaling to NO_SCALE.


Looking at the code, though, everything seems to be pretty much set in stone once the game and its Pixi based renderer have been initialized. Is that correct or have I overlooked something?


So, I'm asking a slightly different question: Is there a simple way to set the size of a non-scaled game canvas from within Phaser?

Share this post

Link to post
Share on other sites

Thanks Rich!


If I understand it correctly, this can be helpful only during game initialisation. But I need to be able to update canvas/game/stage (sorry, I'm little bit confused how to call rendered area) dimensions even during window resize or device rotation as Starnut mentioned. Is there any easy way how to do it?

Share this post

Link to post
Share on other sites

Please see my feature request regarding real resizing. Maybe Rich will integrate it some day.


You could also try it yourself.

Attach a window resize handler, use the method game.renderer.resize and update the settings of the phaser world like world bounds and the input bounds. Unfortunately you can't simply use my example in the github issue. There are some missing parts.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.