diff --git a/src/jugando.ts b/src/jugando.ts index 864e2b5..e22750f 100644 --- a/src/jugando.ts +++ b/src/jugando.ts @@ -318,7 +318,7 @@ export function draw(juego: Juego, timestamp: number) { drawJugadorx(juego); drawSeeds(juego); - if (isMobile()) { + if (isMobile(juego)) { const { left, right } = touchControls(juego); juego.ctx.fillStyle = "rgba(0, 0, 0, 0.3)"; diff --git a/src/utils.ts b/src/utils.ts index 6c388d1..f3d287f 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -63,13 +63,8 @@ export function randomFromArray(array: T[]): T { return array[Math.floor(Math.random() * array.length)]; } -export function isMobile(): boolean { - try { - document.createEvent("TouchEvent"); - return true; - } catch (e) { - return false; - } +export function isMobile(juego: Juego): boolean { + return !!juego.touches; } export function isTouching(juego: Juego, box: Box): boolean {