[FIXED] Previous bug fixed
This commit is contained in:
parent
e90a424e54
commit
86e0b45a2f
@ -11,17 +11,21 @@ export function init() {
|
||||
}
|
||||
|
||||
export class Game {
|
||||
_pageIsInView = true;
|
||||
|
||||
constructor(width = 416, height = 416, ctx) {
|
||||
this.gameField = new GameField(width, height, ctx, canvas);
|
||||
this.gameKeyAdapter = new TankKeyAdapter(this.gameField.tank);
|
||||
|
||||
window.addEventListener("blur", () => { this._pageIsInView = false; });
|
||||
window.addEventListener("focus", () => { this._pageIsInView = true; });
|
||||
}
|
||||
|
||||
start() {
|
||||
let prevEv;
|
||||
let holding = (ev) => {
|
||||
if (!prevEv || prevEv.key != ev.key) return;
|
||||
if (document.visibilityState == "hidden") {
|
||||
alert("I'm hidden");
|
||||
if (!this._pageIsInView) {
|
||||
prevEv = undefined;
|
||||
return;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user