Running multiple animations at the same time

edited January 2018 in Questions about Code

Hey guys,

I'm new at Processing and I don't know what to do.

I want a animation running at millis()= 0 and the same animation starting a second later. The problem is that the second animation isn't running. Just the frame at this time will be displayed. What can I do so that the first animation doesn't stop, when the second starts or how to start the second and let it run while the third starts?

This is the animation which should start several times:

 stroke(0,0,0);
 int bsize = player.bufferSize();

for (int i = 0; i < bsize; i+=4)
 {  
  float x=(r)*cos(i*2*PI/bsize);
    float y = (r)*sin(i*2*PI/bsize);
    float x2 = (r + (player.right.get(i)*120)+10)*cos(i*2*PI/bsize);
    float y2 = (r + (player.left.get(i)*120)+10)*sin(i*2*PI/bsize);
    line(x2, y2, x, y);}

For setting the time I wrote :

if (millis()>startTime+500){
 startTime=millis();
translate(random(0,width), random(0,height));

But it doesn't work well, because the previous animation stops when the next starts and the next doesn't really start, because there is animation after it starting.

Thanks for helping!

Tagged:

Answers

  • Please format your code. Edit your post (gear on top right side of any of your posts), select your code and hit ctrl+o. Leave an empty line above and below your block of code. Details here: https://forum.processing.org/two/discussion/15473/readme-how-to-format-code-and-text

    What makes your first animation different from your second animation (or the third)? From your code, it seems all your animations are clones of each other but placed in different locations in your sketch area. Is that correct?

    Kf

  • Thanks for the advice!

    There is no difference. It's always the same animation. I want them to pop up random at the screen. But I want them starting time-displaced and proceeding when the next animation is starting. And maybe every animation could stop after a time period?

Sign In or Register to comment.