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
loopING (Read 331 times)
loopING
Aug 11th, 2008, 7:43am
 
So this is an extremely fundamental question. I'm having problems getting the loop() function to work. Ideally, the program will restart with the click of the mouse, but it's not working. Can anyone tell me what I'm doing wrong?


int frame = 0;

void setup () {
 size (1000,800);
 smooth ();
 fill (0);
 background (random(210,255));
}

void draw () {
strokeWeight (random (.05,.2));
 println(frameCount);
 line (10, random (10,990), 990, random (10,990));
 if ((frameCount % 500)==0) {
 saveFrame("x-####.tif");
 }
}
 
void mousePressed () {
loop ();
frame =0;
}
Re: loopING
Reply #1 - Aug 11th, 2008, 4:36pm
 
try

http://processing.org/reference/loop_.html
http://processing.org/reference/redraw_.html
Re: loopING
Reply #2 - Aug 11th, 2008, 6:12pm
 
if i get it right, all you want to do is start again, so calling background and clear the screen should be enough. no need to use, loop noloop...

try this :

void mousePressed () {
 background (random(210,255));
}
Re: loopING
Reply #3 - Aug 12th, 2008, 8:18am
 
Thanks Cedric.
Page Index Toggle Pages: 1