//这是我的代码块
var fruitObj = function() {
this.alive = [];//boolen
this.x = [];
this.y = [];
this.l = [];
this.orange = new Image();
this.blue = new Image();
};
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.l[i] = 0;
this.bron(i);
}
this.orange.src = "./src/fruit.png";
this.blue.src = "./src/blue.png";
};
fruitObj.prototype.draw = function() {
for (var i = 0; i < this.num; i++) {
console.log(deltaTime);//可打印出deltaTime数值
if (this.l[i]<=15) {
console.log(deltaTime);//打印出NaN
this.l[i]+=0.01 *deltaTime;
//console.log(this.l[i]);//同样NaN
}
ctx2.drawImage(this.orange,this.x[i] - this.l[i] * 0.5,this.y[i]-this.l[i] * 0.5,this.l[i],this.l[i]);
}
};
fruitObj.prototype.update = function() {
var num = 0;
for (var i = 0; i < this.num; i++) {
if (this.alive[i]) {
num++;
}
}
};
fruitObj.prototype.bron = function(i) {
var aneID = Math.floor(Math.random()*ane.num);
this.x[i] = ane.x[aneID];
this.y[i] = canHeight- ane.len[aneID];
};