trying to delay a loop
in
Programming Questions
•
1 year ago
I'm trying to delay my for loop in draw so the rectangles appear one at a time with 3 seconds delay rather than all appearing after an initial delay of 3 seconds. Can anyone see why the latter is happening and not the former? Delay() does not work and I've read much about how it is not appropriate for many contexts.
Thanks for any help.
-
int[] x = new int[3];
void setup() {size(400,300);background(0);smooth();for(int i=0;i<3;i++) {x[i] = i*100;}}void draw(){boolean keepWaiting=true;int timeSinceLastLetter = millis();for(int i = 0; i < 3; i++){println(timeSinceLastLetter);rect(x[i],100,50,50);timeSinceLastLetter = millis();while (keepWaiting){while (millis()- timeSinceLastLetter < 3000){keepWaiting=true;}keepWaiting=false;}}}
1