Godot: HTML5 Game won't resize when browser window size is changed

Created on 2 Mar 2018  路  4Comments  路  Source: godotengine/godot

Godot version:
Godot 3.0 and 3.0.1

OS/device including version:
HTML5 using Firefox 58

Issue description:
Setting Size: Resizeable=true and Stretch: Mode=viewport, Aspect=keep in the project settings results in properly resizeable game windows for Linux and Windows exports.

Those settings, however, seem to do nothing when playing the game in the browser (HTML5 export). The game stays at the width and height specified in the project settings instead of being stretched to the new window size. If the browser window is too small the game will be cropped in width or height accordingly.

Steps to reproduce:
To reproduce the issue you can download the 2d game Escape the Creeps!. In Project Settings/General/Display/Window set Size: Resizeable=true and Stretch: Mode=viewport, Aspect=keep and start the exported HTML5 game with Firefox.

bug html5 porting

Most helpful comment

Same here. The canvas element isn't even set to the Width and Height under Display > Window, which would make some kind of sense, but rather it's set to Test Width and Test Height.

Found a workaround in #9126 (of which this is probably a duplicate):

OS.set_window_maximized(true)

All 4 comments

Same here. The canvas element isn't even set to the Width and Height under Display > Window, which would make some kind of sense, but rather it's set to Test Width and Test Height.

Found a workaround in #9126 (of which this is probably a duplicate):

OS.set_window_maximized(true)

CC @eska014

@ttencate Thx. This workaround works. I slightly modified it. I put

if OS.get_name()=="HTML5":
OS.set_window_maximized(true)
into func _ready(): of the Main node. The game now stretches to fit the browser window but won't maximize the window of the Linux/Windows exports. It did the latter when not restricting it to HTML5.

Resolved by #21336

Was this page helpful?
0 / 5 - 0 ratings