We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi there, I would know how can I do timing animations in processing. For example: in an animation, 10 seconds after the sketch has been run, a CAR comes in from the left side of the screen and goes out from right . Then, at 20th second, a PLANE comes in from the left side and goes out from right . At 30th second, BLUE car comes in and goes out . And so on....
Answers
you can use millis()
Store the millis at end of setup() in a var startTime
Then calculate the time since that:
passedTime = startTime - millis() ;
if this value is >= 10 etc. trigger the event
Thanks Frank, but could you show me in a simple example with code
Thanks for the answer Ater, but after 10 second, how can I cancel this loop, and for example, at the 11th second an ellipse come in ?
You could make an array of objects TimeEvent - a class which you then have to write
Each object holds when to start and when to stop and what
Just have
void animation2()
and do the same, if you want to stop previous animation on 11s second, line 11 should be if (millis() - startTime > 10000 && millis() - startTime < 11000)https://forum.Processing.org/two/discussions/tagged/timertask
Thanks a lot guys