繪制果實偏移的原因是因為lineWidth和lineCap兩個屬性,指定lineWidth,canvas繪制邏輯是是指定x坐標左右各8px的寬度這樣繪制,lineCap屬性會增加8px的高度 所以果實的位置x和y各偏移了8px
2017-07-21
原background.js:
function drawBackground(){
bgPic.onload=function(){
ctx2.drawImage(bgPic,0,0,canWidth,canHeight);
}
}
修改后的:
function drawBackground(){
ctx2.drawImage(bgPic,0,0,canWidth,canHeight);
}
解決了海葵透明度問題和漂浮直線問題
function drawBackground(){
bgPic.onload=function(){
ctx2.drawImage(bgPic,0,0,canWidth,canHeight);
}
}
修改后的:
function drawBackground(){
ctx2.drawImage(bgPic,0,0,canWidth,canHeight);
}
解決了海葵透明度問題和漂浮直線問題
2017-07-11