不顯示,求看代碼有什么錯誤嗎。我已經(jīng)研究了兩天了。
var fruitObj=function()//果實類
{
this.alive = [];//bool
this.x = [];//
this.y = [];//
this.orange = new Image();
this.blue = new Image();//果實形態(tài)2
}
fruitObj.prototype.num = 30;
fruitObj.prototype.init=function()
{
for (var i = 0; i < this.num; i++) {
this.alive[i]=true;//初始化果實為激活狀態(tài)
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("初始化執(zhí)行");
}
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("畫果實執(zhí)行");
}
fruitObj.prototype.born=function(i){//記錄隨機海葵位置,果實長在???/p>
var aneID =Math.floor(Math.random()*ane.num);//??臄?shù)量隨機找一個
this.x[i]=ane.x[aneID];
this.y[i]=canHeight - ane.height[aneID];
console.log("果實出生執(zhí)行");
}