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.
IndexProgramming Questions & HelpSyntax Questions › sequential animations
Page Index Toggle Pages: 1
sequential animations (Read 411 times)
sequential animations
Apr 17th, 2006, 4:06pm
 
bit of help needed(again)

this one has less reading!

I am using the sequential animation example given in the learning/examples/sequential page. In the bit of code below, would anyone be able to tell me how to get the animation to loop only 4 times ( then another animation to play).

any help much appreciated!

void setup()
{
 size(200, 200);
 framerate(30);
 
 images[0]  = loadImage("PT_anim0000.gif");
 images[1]  = loadImage("PT_anim0001.gif");
 images[2]  = loadImage("PT_anim0002.gif");
 images[3]  = loadImage("PT_anim0003.gif");
 images[4]  = loadImage("PT_anim0004.gif");
 images[5]  = loadImage("PT_anim0005.gif");
 images[6]  = loadImage("PT_anim0006.gif");
 images[7]  = loadImage("PT_anim0007.gif");
 images[8]  = loadImage("PT_anim0008.gif");
 images[9]  = loadImage("PT_anim0009.gif");
 images[10] = loadImage("PT_anim0010.gif");
 images[11] = loadImage("PT_anim0011.gif");
 
 }

void draw()
{
 frame = (frame+1)%numFrames;  // Use % to cycle through frames
 image(images[frame], 0, 0);
}

Re: sequential animations
Reply #1 - Apr 17th, 2006, 10:11pm
 
int hasPlayed=0;

void setup()
{
 size(200, 200);
 framerate(30);
 
 images[0]  = loadImage("PT_anim0000.gif");
 images[1]  = loadImage("PT_anim0001.gif");  
 images[2]  = loadImage("PT_anim0002.gif");
 images[3]  = loadImage("PT_anim0003.gif");  
 images[4]  = loadImage("PT_anim0004.gif");
 images[5]  = loadImage("PT_anim0005.gif");  
 images[6]  = loadImage("PT_anim0006.gif");
 images[7]  = loadImage("PT_anim0007.gif");  
 images[8]  = loadImage("PT_anim0008.gif");
 images[9]  = loadImage("PT_anim0009.gif");  
 images[10] = loadImage("PT_anim0010.gif");
 images[11] = loadImage("PT_anim0011.gif");  

 images2[0]  = loadImage("PT_anim20000.gif");
 images2[1]  = loadImage("PT_anim20001.gif");  
 images2[2]  = loadImage("PT_anim20002.gif");
 images2[3]  = loadImage("PT_anim20003.gif");  
 images2[4]  = loadImage("PT_anim20004.gif");
 images2[5]  = loadImage("PT_anim20005.gif");  
 images2[6]  = loadImage("PT_anim20006.gif");
 images2[7]  = loadImage("PT_anim20007.gif");  
 images2[8]  = loadImage("PT_anim20008.gif");
 images2[9]  = loadImage("PT_anim20009.gif");  
 images2[10] = loadImage("PT_anim20010.gif");
 images2[11] = loadImage("PT_anim20011.gif");  
 
 
 }  
 
void draw()  
{  
 frame = (frame+1)%numFrames;  //This is assuming that the animations have the same number of frames
 if(hasPlayed<4)
 {
   image(images[frame], 0, 0);
 }else{
    image(images2[frame], 0, 0);
 }
}
Page Index Toggle Pages: 1