CIS 3.5 - Spring 2010 Advanced Processing Animation Example #2 M. Meyer */ /** ******************** Variables: Variables provide a way to save information within your sketch and use it to control the size, position, shape, etc. of what you are drawing. */ int numFrames = 4; // The number of frames in the animation int frame = 0; PImage[] images = new PImage[numFrames]; /** ******************** setup(): Use setup() to specify things that need to be done once, when the sketch first opens. */ void setup() { size( 200, 200 ); frameRate( 20 ); images[0] = loadImage("PT_anim0000.gif"); images[1] = loadImage("PT_anim0001.gif"); images[2] = loadImage("PT_anim0002.gif"); images[3] = loadImage("PT_anim0003.gif"); } /** ******************** Use draw() to specify things that you want to have done repeatedly. NOTE: draw() must be present in your program, even if it is left empty. */ void draw() { frame = ( frame + 1 ) % numFrames; // Use % to cycle through frames image( images[frame], 50, 50 ); } /** ******************** Event Listners: Use event-listners like keyPressed() to allow users of your program to cause things to happen. */ /** ******************** Functions: Functions are sections of code that you create and name.

Source code: BitmapAnimation

Built with Processing