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
counter (Read 796 times)
counter
Dec 4th, 2006, 12:01am
 
I try to write a numeric counter 0>9, I want to view all numbers 0,1,2,...,9 with 3 seconds between this. The delay command don't run and I can't use framerate command.
Thanks

code:
PFont font;
size(200,200);
font = loadFont("Arial.vlw");
textFont(font, 32);
fill(0);
for (int i=0;i<=9;i++) {
 background (255);
 text(i, 15, 60);
 delay(3000);
 println(i);
}
Re: counter
Reply #1 - Dec 4th, 2006, 4:00am
 
this will work.

PFont font;
int time, num, mydelay;

void setup(){
 size(200,200);
 font = loadFont("Arial.vlw");  
 time = 0;
 num = 0;
 mydelay = 3000;
 textFont(font, 32);
 fill(0);  
}

void draw(){
 time = millis();
 background(255);
 text(num,width/2,height/2);
 if(time > (num+1)*3000){
   if(num == 9){
     time = num = 0;
   }
   else
     num++;
 }
}
Page Index Toggle Pages: 1