淋雨的兔子
2015-10-05 15:59
for(var i = 0;i<this.num;i++){
if(this.alive[i]){
if(this.r[i]<10){
this.r[i] += this.speed[i]*gaptime*0.1;
}else{
if(this.y[i]<0){
this.alive[i] = false;
}else{
this.y[i] -= this.speed[i]*gaptime;
this.r[i] += this.speed[i]*gaptime*0.01;
}
}
context1.beginPath();
context1.arc(this.x[i],this.y[i],this.r[i],0,2*Math.PI);
context1.fillStyle = this.color[i];
context1.strokeStyle = "rgba(255,255,255,1)";
context1.fill();
context1.stroke();
context1.closePath()
context1.beginPath();
context1.arc(this.x[i]-2,this.y[i]-2,this.r[i]/4,0,2*Math.PI);
context1.fillStyle = "rgba(255,255,255,1)"
context1.fill();
context1.closePath()
}
}
因为 if(this.alive[i]) 为 false 的时候不会执行绘制,会跳过当前循环,导致失帧, 所以会闪一下
HTML5小游戏---爱心鱼(上)
92348 学习 · 551 问题
相似问题