我的圓圈好像設(shè)置樣式并沒有用,而且消失的特別快,求幫助
waveObj.prototype.draw=function(){
ctx1.save();
ctx1.linWidth=2;
ctx1.shadowBlur=10;
ctx1.shadowColor="white";
for(var i=0;i<this.num;i++){
if(this.alive[i]){
this.r[i]+=deltatime+0.05;//半徑逐漸變大
if(this.r[i]>60){
this.alive[i]=false;
break;
}?
var alpha=1-this.r[i]/60;//r與alpha成反比
//draw ?canvas arc()繪制圓的方法
ctx1.beginPath();
ctx1.arc(this.x[i],this.y[i],this.r[i],0,Math.PI*2);
ctx1.strokeStyle="rgba(255,255,255,"+alpha+")";
ctx1.stroke();
ctx1.closePath();
}
}
ctx1.restore();
}
2017-07-06
ctx1.linWidth=2;//拼寫錯(cuò)誤lineWidth
this.r[i]+=deltatime+0.05;//半徑逐漸變大
//你寫的是deltatime+0.05,應(yīng)該是deltatime*0.05才減小半徑增長(zhǎng)速度吧。
//細(xì)心啊,少年!