/*Drew Cogbill Image 2.1 [computation08]*/ //numFrames is the number of animated frames int numFrames = 11; //Array to hold the animated frames PImage[] images = new PImage[numFrames]; void setup() { size(360, 230); frameRate(20); //Need to load the images first //One way is to insert each image into the array /* images[0] = loadImage("000muy.jpg"); images[1] = loadImage("001muy.jpg"); images[2] = loadImage("002muy.jpg"); images[3] = loadImage("003muy.jpg"); images[4] = loadImage("004muy.jpg"); images[5] = loadImage("005muy.jpg"); images[6] = loadImage("006muy.jpg"); images[7] = loadImage("007muy.jpg"); images[8] = loadImage("008muy.jpg"); images[9] = loadImage("009muy.jpg"); images[10] = loadImage("010muy.jpg"); */ //This is a great time to use a for loop to populate our array //Note that the image numbers start with 000 for (int i = 0; i < images.length; i++) { //the nf() function gives us more control over number formatting //we want a int with 3 places, the first value is the int value //the second value is the number of digits String imageName = nf(i, 3) + "muy.jpg"; images[i] = loadImage(imageName); } } void draw() { //We'll use the % to cycle thru the frames int frame = frameCount % numFrames; image(images[frame], 0, 0); }