为什么我声明对象后,RUN,只能出现一个眼睛?
EYE hieye1; //对象部分
EYE hieye2;
void setup(){
size(600,600);
smooth();
hieye1=new EYE(color(255,100,0),100,200,100);
hieye2=new EYE(color(255,100,0),200,100,50);
}
void draw(){
background(125);
hieye1.kill();
hieye1.move();
hieye2.kill();
hieye2.move();
}
class EYE{ //定义类 类的部分
color c; //类的变量
float x;
float y;
float xspeed;
float d;
float s;
EYE(color tempc,float tempx,float tempy,float tempd){ //定义类的构造函数
c=color(255,200,0);
x=width/2;
y=height/2;
xspeed=1;
d=50;
s=1;
}
void kill(){ //定义的类中所有的对象该做的事情
stroke(0);
strokeWeight(d/15);
fill(255);
ellipse(x,y,d*2,d);
strokeWeight(d/20);
fill(c);
ellipse(x,y,d,d);
fill(0);
noStroke();
ellipse(x,y,d/3,d/3);
}
void move(){
x=x+xspeed*s;
if(x>width||x<d/2){
s=-s;
}
}
}