learning processing 为啥他说 the constructor cow(float,float, int) is undefined
cow[]cows=newcow[15];voidsetup(){size(600,400);smooth();for(inti=0;i<cows.length;i++)...
cow[] cows = new cow[15];
void setup(){
size(600,400);
smooth();
for(int i = 0; i < cows.length; i++){
cows[i] = new cow(random(width),random(height),50);
}
}
void draw(){
background(255);
for(int i = 0; i < cows.length; i++){
cows[i].display();
}
}
class cow{
float x;
float y;
float sz;
cow(float x_,float y_,float sz_){
x = x_;
y = y_;
sz = sz_;
}
void display(){
rectMode(CENTER);
//feet
rect(x-15,y+70,0.2*sz,0.2*sz);
rect(x,y+70,0.2*sz,0.2*sz);
rect(x-70,y+70,0.2*sz,0.2*sz);
rect(x-85,y+70,0.2*sz,0.2*sz);
//body
rect(x-40,y+30,2.5*sz,1.5*sz);
//head
rect(x,y,sz,sz);
//ears
rect(x+20,y-25,0.2*sz,0.2*sz);
rect(x-20,y-25,0.2*sz,0.2*sz);
//eyes
rect(x+10,y-10,0.1*sz,0.1*sz);
rect(x-10,y-10,0.1*sz,0.1*sz);
//mouth
rect(x,y+10,0.5*sz,0.3*sz);
}
}
不重命名文件 用这个CODE是可以的 为什么给他改革名字就不行了....例如名字叫cow 展开
void setup(){
size(600,400);
smooth();
for(int i = 0; i < cows.length; i++){
cows[i] = new cow(random(width),random(height),50);
}
}
void draw(){
background(255);
for(int i = 0; i < cows.length; i++){
cows[i].display();
}
}
class cow{
float x;
float y;
float sz;
cow(float x_,float y_,float sz_){
x = x_;
y = y_;
sz = sz_;
}
void display(){
rectMode(CENTER);
//feet
rect(x-15,y+70,0.2*sz,0.2*sz);
rect(x,y+70,0.2*sz,0.2*sz);
rect(x-70,y+70,0.2*sz,0.2*sz);
rect(x-85,y+70,0.2*sz,0.2*sz);
//body
rect(x-40,y+30,2.5*sz,1.5*sz);
//head
rect(x,y,sz,sz);
//ears
rect(x+20,y-25,0.2*sz,0.2*sz);
rect(x-20,y-25,0.2*sz,0.2*sz);
//eyes
rect(x+10,y-10,0.1*sz,0.1*sz);
rect(x-10,y-10,0.1*sz,0.1*sz);
//mouth
rect(x,y+10,0.5*sz,0.3*sz);
}
}
不重命名文件 用这个CODE是可以的 为什么给他改革名字就不行了....例如名字叫cow 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询