Hi everyone ,I encountered some difficulties in the code.
I want to create a new gif when I click the mouse . But it can’t work 。It said The constructor Gif(bodycreate.Particle, String) is undefined. The following is part of my code. I really need some help!
class Particle {
PVector location;
PVector velocity;
PVector acceleration;
float r,g,b;
float lifespan;
Gif bodyloopingGif;
float y;
float easing = 0.05;
Particle(int ID) {
// The acceleration
bodyloopingGif = new Gif(this, "1.gif");//The constructor Gif(bodycreate.Particle, String) is
//undefined (in here)
bodyloopingGif.loop();
acceleration = new PVector(0, 0);
// circel's x and y ==> range
velocity = new PVector(0, 0);
// apawn's position
location = new PVector(width/2, 0);
y = 9*height/10;
// the circle life time
lifespan = 255.0;
r = random(0,255);
g = random(0,255);
b = random(0,255);
location.y = y;
}
void run() {
//update();
display();
}
void update(float yy) {
float y = yy;
if(location.y != y)
{
float dy = y - location.y;
location.y += dy * easing;
}
//lifespan-=1.0;
}
boolean isDead() {
if (lifespan <= 0) {
return true;
} else {
return false;
}
}
void display() {
// border
stroke(0, lifespan);
// border's weight
strokeWeight(1);
// random the circle's color
// random the circle's color
fill(r,g,b, lifespan);
// draw circle
// ellipse(location.x, location.y, 3, 3);
rect(location.x, location.y, 100, 100);
}
}