1 decade ago by sunnybubblegum
This is more of a JavaScript question about using
In my game I have a 'toggle fullscreen' button that expands the viewport to fill the browser window. It's working successfully. The issue lies with resizing the browser window while in 'fullscreen mode'. I'm trying to do the following.
main.js ('update' section)
The
the viewport resizes nicely upon resizing the browser. Only with this, it begins in 'fullscreen mode', and won't let me toggle out.
I need
window.onresize
.In my game I have a 'toggle fullscreen' button that expands the viewport to fill the browser window. It's working successfully. The issue lies with resizing the browser window while in 'fullscreen mode'. I'm trying to do the following.
main.js ('update' section)
if (this.fullscreen && window.onresize) { ig.system.resize(document.body.clientWidth, document.body.clientHeight); }
The
window.onresize
is having no effect when placed inside an if
statement and the game is in 'fullscreen mode'. Yet with this..window.onresize = ig.system.resize(document.body.clientWidth, document.body.clientHeight);
the viewport resizes nicely upon resizing the browser. Only with this, it begins in 'fullscreen mode', and won't let me toggle out.
I need
window.onresize
to run ig.system.resize
only if the user resizes the browser while in 'fullscreen mode'. Any experience using this event?