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

428
Views
¿Cómo puedo obtener un bucle en la configuración () para restablecer?

Tengo un bucle for en function setup() que me gustaría restablecer y volver a ejecutar cuando mi juego se restablezca. El propósito de restablecer el bucle es hacer que todos los objetos de la matriz vuelvan a su posición y color de inicio, o simplemente crear objetos completamente nuevos.

 function setup() { createCanvas(550, 550) for(let i = 0; i<200; i++) { x = random(width) y = -50 - 50 * i r = random(15,50) enemies[i] = new Enemy (x, y, r) } }

Me imagino que no podré hacer esto directamente ya function setup() solo puede ejecutarse una vez, entonces, ¿hay alguna solución para restablecer la setup () for loop?

Enlace al código completo aquí si es necesario

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Mueva el código relevante para restablecerlos a otra función, tal vez, reset() . Luego puede llamar a reset() desde setup() , y también llamar a reset() cada vez que necesite restablecerlos.

about 4 years ago · Juan Pablo Isaza Report
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!