HTML5 canvas resize not reported to engine (SOLVED)

Thank you for the info!

Canvas width / height cannot be set with CSS for this to work. It must be set directly in the tag values for the engine to see them.

function resize_game_canvas() {
var app_continer = document.getElementById('app-container');
app_continer.style.width = window.innerWidth;
app_continer.style.height = window.innerHeight;

var game_canvas = document.getElementById('canvas');
game_canvas.width = window.innerWidth;
game_canvas.height = window.innerHeight;
}

resize_game_canvas();

window.addEventListener('resize', resize_game_canvas, false);
window.addEventListener('orientationchange', resize_game_canvas, false);

This works! Also I think a mistake I made earlier was using the wrong render script. :disappointed_relieved:

Here is the example uploaded here to show it working: https://www.bookofdefold.com/examples/FullWindowCanvas/

It should work “well” on mobile devices too, and handle orientation change for web apps.

4 Likes