Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

147
Vistas
How to prevent screen holding on "touchstart"?

I’m trying to create a small game as a learning experience and I’m having trouble adding a jump function. The game is for mobile touch screens.

Essentially I have a gravity variable which is applied to the player on the canvas (which works fine) and an accelerate function for up/down movement.

I need to be able to tap the screen and have the "player" jump, then fall back down. so far I have:

document.addEventListener
(“touchstart”,jump) 
function jump() {
 accelerate(-0.5);
}

document.addEventListner
("touchend”,fall)
function fall() {
 accelerate(0.4)
}

I might not have remembered what I wrote exactly, but the above code works for rising and falling, the problem however is if the user holds the screen, the player will just keep rising. Now obviously logically this is to be expected but I want more of a tap screen to jump type thing

so is there a way to have the accelerate run once when the user taps the screen, perhaps for a set duration then stops, until the screen is tapped again?

sorry for the long post

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda