不显示,求看代码有什么错误吗。我已经研究了两天了。
var fruitObj=function()//果实类
{
this.alive = [];//bool
this.x = [];//
this.y = [];//
this.orange = new Image();
this.blue = new Image();//果实形态2
}
fruitObj.prototype.num = 30;
fruitObj.prototype.init=function()
{
for (var i = 0; i < this.num; i++) {
this.alive[i]=true;//初始化果实为激活状态
this.x[i]=0;
this.y[i]=0;
this.born(i);
}
this.orange.src="./img/fruit.png"
this.blue.src="./img/blue.png"
console.log("初始化执行");
}
fruitObj.prototype.draw=function(){//画果实
for (var i = 0; i < this.num; i++) {
ctx2.drawImage(this.orange, this.x[i] - this.orange.width * 0.5,this.y[i] - this.orange.height * 0.5);
}
console.log("画果实执行");
}
fruitObj.prototype.born=function(i){//记录随机海葵位置,果实长在海葵上
var aneID =Math.floor(Math.random()*ane.num);//海葵的数量随机找一个
this.x[i]=ane.x[aneID];
this.y[i]=canHeight - ane.height[aneID];
console.log("果实出生执行");
}