I’m currently testing how to export an HTML5 game, for example to Poki.
I’d like to detect the screen dimensions where the game is running and automatically adjust everything for either horizontal (default) or vertical orientation.
However, when I test the HTML5 version, I’m stuck in horizontal mode.
Even when I try it on inspector.poki.dev, it always remains in landscape.
I’m not sure if this is due to something in HTML code or another setting.
Here are my current settings:
Display Width: 1031
Display Height: 580
High DPI: Yes
Dynamic Orientation: Yes
HTML5 Scale Mode: Fit
What do you usually do to make your HTML5 games support both portrait and landscape modes?
Thanks in advance for any tips or suggestions that can point me in the right direction!
What do you mean by stuck in horizontal mode? When you say “adjust everything for either horizontal or vertical orientation” what do you mean by “everything”?
For GUI you can use layouts and the GUI should adjust if the orientation changes. For the rest of your content (sprites etc) you can listen for window size changes using window.set_listener() and react to changes in window size.
The “stretch” mode fixed the screen filling issue. Thank you very much.
But now I’m experiencing a strange behavior shown in the video below (the ship is positioned at the mouse position). It also happens in the Windows version as well as in HTML5.