我正在進行彈跳計劃。 我想畫牆並設置牆的線寬。 爲了設置牆的線寬,我添加了「ctx.linewidth = 30;」那就是我的代碼中寫成第3行的 。 但沒有發生。 我很想知道線寬,我改變了ctx.linewidth = 50; 仍然沒有發生。 如何設置牆的線寬?爲什麼linewidth沒有設置?
function init() {
ctx=document.getElementById('canvas').getContext('2d');
ctx.linewidth=30;
ctx.fillStyle="rgb(200,0,50)";
moveball();
setInterval(moveball, 700);
}
function moveball() {
ctx.clearRect(boxx,boxy,boxwidth,boxheight);
moveandcheck();
ctx.beginPath();
ctx.arc(ballx,bally,ballrad,0,Math.PI*2,true);
ctx.fill();
ctx.strokeRect(boxx,boxy,boxwidth,boxheight);
document.getElementById('px').value=ballx;
document.getElementById('py').value=bally;
}
它'ctx.lineWidth'不'ctx.linewidth'以大寫W¯¯ – Blindman67