Open misch27 opened 2 years ago
For future reference:
I fixed this problem by calling requestFullScreen
on a new div I wrapped around the game canvas.
<div id="game">
<canvas id="canvas" oncontextmenu="event.preventDefault()"></canvas>
</div>
goFullScreen
function: https://github.com/Davidobot/love.js/blob/c4f04e185033a7c9fbefa9be3bec88c41a90421b/src/release/index.html#L22-23 to:
function goFullScreen() {
var canvas = document.getElementById("game");
#canvas
in the <style>
tag at the top:
#canvas {
max-height: 100%;
max-width: 100%;
}
A downside of this is that the canvas wont scale, thus your game wont know that the window changed size. It'll just remain the aspect ratio it was at boot. See this answer for a solution that doesn't have that problem: https://github.com/Davidobot/love.js/issues/88#issuecomment-2005117581 (in combination with full-screen mode: love.window.setMode(600, 920, { fullscreen = true })
)
The canvas coordinates in requestFullScreen are the same as the canvas before full screen mode, although they need to be adjusted.
Found a similar problem here https://stackoverflow.com/questions/43853119/javascript-wrong-mouse-position-when-drawing-on-canvas/43873988