Hey im trying to set my web game orientation based on size of the window


line with seting window size to 810 is not working at all after setting window it is all the wime changing while im changing web browser

I got stretch mode 2d and aspect keep, and i need to keep it. Anyone got any idea why it is not working?

Mydel changed the title to Problem with changing window size .

I find out that i cant change aspect to keep from code it always sets expand, it is loking like keep aspect only works while im seeting it once on start of the app.

You can copy and paste code as text on the forum. Just place 3 tildes ~~~ on a line by themselves, directly above and directly below the code.

In terms of your question, you can change the window size at any point and it will respect the stretch mode and aspect ratio settings.

You don't need to alter anything at run time. If you don't know the resolution ahead of time (which you won't for a full screen game) then set stretch to 2D and aspect to either Keep or Expand.

If you know the game will only be played in landscape (if it is a PC game) then you select Keep Height, and if it's a mobile game that is portrait only, then you can do Keep Width.

In any case, the window will expand to the HTML Canvas size, so any resizing should be done in Javascript or, more usefully, CSS. That way it is dynamic and responsive.