How Use animation in processing
I created a simple animation. To animation work correctly I should use background(0) under draw().
Now I want to use this animation in main processing file. Actually this animation is a class of main file.
But if I use background in class all the background of main file will be affected. What should I do?
- int nFrame =2;
- int frame = 0;
- PImage[] img = new PImage[nFrame];
- void setup()
- {
- frameRate(5);
- img [0] = loadImage("01.gif");
- img [1] = loadImage("02.gif");
- }
- void draw()
- background(0);
- frame++;
- if (frame == nFrame)
- {
- frame =0;
- }
- image(img[frame], 0,0);
- }