We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Ok, I know that is not possible to reset millis() function. But this is not my problem.
The problem is: In my( not only in mine xD) sketch millis() start from 0 to ipothetic infinite time.
I've set a startTime variable = to millis().
Now.. when startTime reach 1000ms something happen. When startTime reach 130000ms something happen and so on..
I want that after the first launch, every 219000ms startTime turn back into 0, to repeat again all the stuff at 1000ms..130000ms etc..
Obviously in the meantime millis() goes on, so I need to reset startTime automatically after others 219000ms..
I've tried with if(),for(),and many other way but at the end of the first 219000ms nothing happened...
I try with an example:
int startTime;
int interval = 5000;
void setup() {
size(400,400);
startTime=millis();
}
void draw() {
if(startTime>2000) {
rect(10,10,10,10);
}
//here I need something to make startTime turn back to 0!
}
There is a solution..? :(
Answers
Just use the modulo operator:
o.O so simple? I really really thank you _
(Many days passed on timed animations without find a way to make them restart have get me crazy XD)
thanks thanks thanks ^^
Haha, yes, Java/Processing has a bunch of uselful operators. :D
Btw.: Please mark my last post as answer, so others can see that this question has been answered.
Oh yes, made it! ;) Thanks again:)