fruit出不來(lái)啊,
Uncaught SyntaxError: Unexpected token ILLEGAL
?這個(gè)說(shuō)是for(var i=0;i<this.num;i++)錯(cuò)了
代碼
var?fruitObject=function(){ this.alive=[];//boolean this.orange=new?Image(); this.bliue=new?Image(); this.x=[]; this.y=[]; } fruitObject.prototype.num=30; fruitObject.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="./src/fruit.png"; this.blue.src="./src/blue.png"; } fruitObject.prototype.draw=function(){ for(var?i=0;i<this.name;i++){ ctx2.drawImage(this.orange,this.x[i],this.y[i]); } } fruitObject.prototype.born=function(i){ var?aneid=Math.floor(Math.random()*ane.num); this.x[i]=ane.x[aneid]; this.y[i]=canHeight-ane.length[aneid]; ? }
2016-01-21
第四行blue寫成了bliue,draw后面for中的i<this.num 寫錯(cuò)了,寫成 name了