慕哥0728771
2018-07-07 11:12
fruitObj.prototype.draw=function () { for(var i=0;i<this.num;i++){ // draw // find a ane,grow,fly up if(this.l[i]<=14){ this.l[i]+=0.01*daltaTime; } else{ this.y[i]-=0.07*daltaTime } 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]) } } //果实状态,允许15个 fruitObj.prototype.update=function () { var num=0; for(var i=0;i<num;i++){ if(this.alive[i]){ num++ } } } fruitObj.prototype.born=function (i) { // 找到坐标 // 问题:不用取整,无法获得ID var aneId=Math.floor(Math.random()*ane.num); this.x[i]=ane.x[aneId]; this.y[i]=canHeight-ane.y[aneId] this.l[i]=0; }
fruitObj.prototype.draw=function () { ctx2.clearRect(0,0,canWidth,canHeight);//加上这句就行了 for(var i=0;i<this.num;i++){ // draw // find a ane,grow,fly up if(this.l[i]<=14){ this.l[i]+=0.01*daltaTime; } else{ this.y[i]-=0.07*daltaTime } 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]) } }
HTML5小游戏---爱心鱼(上)
92350 学习 · 551 问题
相似问题