It still doesn't work, this is my code
declare let document;
let inGameMusicPlayer = new Sup.Audio.SoundPlayer("Sound", 1.0, { loop: true });
class MouseCoordsBehavior extends Sup.Behavior {
update() {
// Mouse coordinates returned by .getMousePosition() are normalized to (-1, 1)
let { x, y } = Sup.Input.getMousePosition();
x = (x + 1) / 2 * Sup.Input.getScreenSize().x;
y = (1 - (y + 1) / 2) * Sup.Input.getScreenSize().y;
this.actor.textRenderer.setText(`X = ${Math.round(x)}\nY = ${Math.round(y)}`);
if (x >= 0 && x <= 170 && y >= 0 && y <= 170 && Sup.Input.wasMouseButtonJustReleased(0)) {
this.actor.textRenderer.setText("OMG BUTTONS");
handleVisibilityChange();
}
}
}
Sup.registerBehavior(MouseCoordsBehavior);
function handleVisibilityChange() {
if (document.hidden) inGameMusicPlayer.pause();
else inGameMusicPlayer.play();
}
document.addEventListener("webkitvisibilitychange", handleVisibilityChange, false);