问答详情
源自:2-7 大鱼绘制

fruit执行alive = false的时候 其余所有果实为何总会会闪一下

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()

}

}


提问者:淋雨的兔子 2015-10-05 15:59

个回答

  • n4ocMa
    2016-09-13 09:57:01
    已采纳

    因为 if(this.alive[i]) 为 false 的时候不会执行绘制,会跳过当前循环,导致失帧, 所以会闪一下