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
Timed animation (Read 436 times)
Timed animation
Dec 1st, 2007, 8:39pm
 
Hi,

I'm new to Processing and programming in general, and was therefore very positively surprised by how accessible the language is even to mere newcomer like me. The creative potential is surely limitless from all the great examples I’ve seen so far.

I’m playing around with some animated cubes that react to the beat detection in the Minim library. It’s going to be a bit part of a visualizer we are working on as a university project. The cubes are created randomly (although with randomSeed), trough an object with an array.

My problem is that the animation upon beat lasts only as long as the beat itself, which is a mere millisecond (naturally enough as I'm using the if function). I've been playing around a lot with the for function (and every other possible solution I could come up with), but haven’t been able to make it do what I need; which is play the given animation (upon beat) for x seconds or until the animations is finished, regardless of the change in beat.

All help would be greatly appreciated,

Tor

Re: Timed animation
Reply #1 - Dec 1st, 2007, 9:29pm
 
You probably want something along the lines of:

Code:
int beatTime;
int beatAnimLength=1000; //1 second

//...

if(beat())
{
beatTime=millis();
}

if(millis()<beatTime+beatTimeLength)
{
//draw stuff
}
Re: Timed animation
Reply #2 - Dec 2nd, 2007, 10:55am
 
Thanks a million JohnG. That worked out great  Smiley
Page Index Toggle Pages: 1