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

85
Views
AddEventListener está funcionando en el momento equivocado

Por alguna razón, addEventListener funciona tanto cuando debería funcionar como cuando no debería funcionar. Creé un juego en el que si el jugador no ha perdido, juega, pero solo cuando pierde, puede hacer clic en la pantalla para volver a intentarlo. En el navegador, cuando se abre el juego o se actualiza el navegador, todo funciona bien. Sin embargo, después de la primera pérdida, cualquier clic hace que el juego se reinicie desde el principio. ¿Qué estoy haciendo mal?

 function main() { setTimeout(function everyFrame() { clearCanvas(); //Run if the game isn't over if (!isGameOver()) { game_over = false; //Code for the game screen } //Run if the game is over else if (isGameOver()) { game_over = true; //Code for the lose screen //Reset the game when the user clicks on the lose screen if (game_over) { game_over = false; myCanvas.addEventListener("click", restartGame); } } main(); changingDir = false; }, 100); }
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!