为什么照着老师代码敲,老师的出现果实了,我的没有呢,大家有类似的情况吗
对了那个this.o就是橘子 我的这个我运行可以
fruitObj.prototype.draw = function()
{
for(var i=0;i<this.num;i++)
{
if (this.l[i]<15) {
this.l[i]=this.l[i]+delttime*0.01;
}
else{
this.y[i]-=delttime*0.01;//上浮
ctx1.clearRect(this.x[i] - this.o.width * 0.5,this.y[i] - this.o.height * 0.5,this.l[i]+0.1,this.l[i]+0.1);
}
ctx1.drawImage(this.o, this.x[i] - this.o.width * 0.5,this.y[i] - this.o.height * 0.5,this.l[i],this.l[i]);
}
//console.dir(this.x,this.y);
}
跪求fruit.js代码
粘贴你的代码也出现不了果实
var fruitObj=function()
{
this.alive=[];
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.born(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++)
{
this.l[i]+=0.01*deltaTime;
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.born=function(i)
{
var aneID=Math.floor(Math.random()*ane.num);
this.x[i]= ane.x[aneID];
this.y[i]= canHeight - ane.len[aneID];
this.l[i]=0;
}
/*fruitObj.prototype.update=function()
{
var num=0;
for(var i=0;i<this.num;i++)
{
if(this.alive[i])num++;
}*/
嗯嗯,同求fruit.js代码
我的出现果实了
我的也是的,你现在解决果实不出现的问题了么