mirror of
https://github.com/dyne/FreeJ.git
synced 2026-02-11 07:19:32 +01:00
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
30 lines
603 B
Plaintext
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;
|
|
}
|
|
}
|