Davidobot / love.js

LÖVE ported to the web using Emscripten, updated to the latest Emscripten and LÖVE (v11.5)
MIT License
624 stars 28 forks source link

- Focus window on loading and on clicking #17

Closed Sheepolution closed 4 years ago

Sheepolution commented 4 years ago

When hosting your game on sites like Itch.io, it's not possible to gain focus after losing focus. This means that any key you press will not reach the game. This can be fixed by calling window.focus when the window is clicked.

Davidobot commented 4 years ago

Given the window.onload definition - if a game hides the cursor, would the cursor be hidden as soon as the game loads then? Without having to have the player click on the canvas?

Sheepolution commented 4 years ago

Good question, I'll test this out tomorrow.

Sheepolution commented 4 years ago

When you hide the cursor with love.mouse.setVisible(false), it will only be hidden when you hover over the game's canvas. Even when the game is not focused, so with the committed fix removed, it will be hidden when you hover over the canvas, but still be visible everywhere else.