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
Timer (Read 2085 times)
Timer
Apr 14th, 2008, 8:57pm
 
Hello everybody...

I have a question about timers.

What are the different ways to make a timer using Processing?

I know the basic timer with millis() but somebody told me that it was not elegant...

code:


/////

int timer;
int timelength = 1000;

void setup(){
 timer = millis();
}

void draw(){
 if (millis() - timer < timelength){
      instructions;
  }
 else{
      timer = millis();
      instructions;
   }
}

/////


any sugestion?

Re: Timer
Reply #1 - Apr 16th, 2008, 11:15am
 
Using framerate() and the draw() loop.

Using Java Threads, maybe.

It all depends on what you need to do!
Re: Timer
Reply #2 - Apr 16th, 2008, 11:43am
 
I just want to know the different possibilities...

I don't know how to program a Java Thread... This interests me....

The reason I spend time thinking on how to program a timer is because it's an essential part of programming(for me)... I mean it's important to be able to coordinate actions or to limit instructions in time...
Page Index Toggle Pages: 1