Files
FreeJ/scripts/processing/topics/anisprite.pde
Jaromil ae7b1ad056 progresses on processing script
processing-js 0.4 has been merged in some relevant parts
basic and topic scripts added for test
color handling fixed, more scripts show up now
2010-02-12 18:36:54 +01:00

30 lines
603 B
Plaintext

// Class for animating a sequence of GIFs
class AniSprite {
PImage[] ani;
int frame;
int numFrames;
AniSprite(String imageName, int frameCount) {
numFrames = frameCount;
ani = new PImage[numFrames];
loadImages(imageName);
}
void loadImages(String name) {
for(int i=0; i<numFrames; i++) {
String imageName = name + ((i < 10) ? "0" : "") + i + ".gif";
ani[i] = loadImage(imageName);
}
}
void display(float xpos, float ypos) {
frame = (frame+1)%numFrames;
image(ani[frame], xpos, ypos);
}
int getWidth() {
return ani[0].width;
}
}