Adding a delay between iterations in a for loop?
in
Programming Questions
•
27 days ago
- class Explosion {
// proprietes
float posX; // Position X du "centre" des explosions (le premier point de chaque courbe est le centre)
float posY; // Position Y du centre
int nbrCourbes; // Nombre de courbe dans l'explosion
ArrayList mesCourbes; // Arraylist qui contient mes courbes
// constructeur
Explosion(float posX_, float posY_, int nbrCourbes_) {
posX = posX_;
posY = posY_;
nbrCourbes = nbrCourbes_;
mesCourbes = new ArrayList();
// Creation des courbes dependamment du nombre demande en parametre
float R = random(50, 255);
float G = random(50, 255);
float B = random(50, 255);
for (int i = 0; i < nbrCourbes; i++) {
mesCourbes.add(new Courbe(color(R, G, B)));
}
}
// fonction
void afficher() {
for (int i = 0; i < mesCourbes.size(); i++) {
Courbe c = (Courbe) mesCourbes.get(i);
pushMatrix();
translate(posX, posY);
rotate(radians(i));
c.afficher();
popMatrix();
}
}
}
In my "afficher()" function, I'm trying to add a delay between the displaying of each curve (courbe). I can't seem to figure it out. I've tried millis() all day long with timestamps and whatnot, it just won't work. Basically, I want each of them to appear after the other instead of all of them at the same time when I call Explosion()'s afficher()
1