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.
IndexProgramming Questions & HelpSyntax Questions › exit and restart
Page Index Toggle Pages: 1
exit and restart (Read 726 times)
exit and restart
Oct 30th, 2006, 4:05pm
 

hi there.

i'm stopping my program using the exit() funtion. is there any way to restart it afterwards? does anybody have any tips on how to pause their sketch?

thanks,

jeremy
Re: exit and restart
Reply #1 - Oct 30th, 2006, 10:03pm
 
To pause/play use noLoop/loop.
Here's a little example:

Code:

// click to toggle pause/play
float x, y, spd = 5, d = 20;
int moveState = -1;
void setup(){
size(400, 100);
x = width/2;
y = height/2;
smooth();
}

void draw(){
background(255);
ellipse(x+=spd, y+sin(radians(x*2))*d, d, d);
if (x>=width-d/2 || x<=d/2){
spd*=-1;
}
if (moveState > 0){
noLoop();
}
}

void mousePressed(){
moveState*=-1;
loop();
}


-ira
Re: exit and restart
Reply #2 - Nov 3rd, 2006, 5:45pm
 
thanks ira. that was really helpful.
Page Index Toggle Pages: 1