We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
delay() ?? (Read 617 times)
delay() ??
Apr 21st, 2008, 5:26am
 
How come the following delay() is not working?
Code:
void setup() {
size(400,400);
background(153);
noLoop();
//
for (int i=1; i<100; i++) {
println(i);
delay(2000);
}
//
}//setup()

void draw() {
}//draw()
Re: delay() ??
Reply #1 - Apr 21st, 2008, 10:55am
 
For some reason,  the delay works if you move the loop to draw().
Re: delay() ??
Reply #2 - Apr 21st, 2008, 12:21pm
 
Don't know why but looking at the code for delay() in PApplet there is a line of code at the start that says:

Code:
if (frameCount == 0) return; 



and since in setup frame should be 0 it exits before doing anything ... an alternative would be to use "standard" java code:

Code:
try {
Thread.sleep(2000);
} catch (InterruptedException e) { }


Re: delay() ??
Reply #3 - Apr 21st, 2008, 1:06pm
 
The more important question is why would you want to have a delay in the setup routine? It doesn't make sense.
Page Index Toggle Pages: 1