慕斯卡4545833
2016-10-18 11:38
透明度一直不起作用啊
aneObj.prototype.draw = function(){
ctx2.save();
ctx2.globalAlpha = 0.6;
for (var i = 0; i < this.num; i++) {
//beginPath,moveTo,lineTo,stroke,strokeStyle ,lineWidth,
ctx2.beginPath();
ctx2.moveTo(this.x[i],canHeight);
ctx2.lineTo(this.x[i],canHeight - this.len[i]);
ctx2.lineWidth = 20;
ctx2.lineCap = "round"
ctx2.strokeStyle = "#3b154e";
ctx2.stroke();
}
ctx2.restore();
}
加载不出透明度的原因是一直循环画海葵,重叠了
已经解决了,看到评论里面有一个人的方法是把ane.draw();方法放在
function drawbackground(){
bgPic.onload=function(){
ctx2.drawImage(bgPic,0,0,canWidth,canHeight);
ane.draw();
}
}HTML5小游戏---爱心鱼(上)
92341 学习 · 583 问题
相似问题