Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

136
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!