Detectar el touch de una manera que funcione bien en WebKit

This commit is contained in:
Nulo 2021-07-01 23:12:55 +00:00
parent bb61cb2b1c
commit 12530e5aab
2 changed files with 3 additions and 8 deletions

View File

@ -318,7 +318,7 @@ export function draw(juego: Juego<State>, 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)";

View File

@ -63,13 +63,8 @@ export function randomFromArray<T>(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<any>): boolean {
return !!juego.touches;
}
export function isTouching(juego: Juego<any>, box: Box): boolean {