2017-04-12 98 views
0

我正在進行彈跳計劃。 我想畫牆並設置牆的線寬。 爲了設置牆的線寬,我添加了「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; 

} 
+0

它'ctx.lineWidth'不'ctx.linewidth'以大寫W¯¯ – Blindman67

回答

1

在你的第3行的功能應該是ctx.lineWidth,而不是ctx.linewidth

隨着資本W.

+0

事實上,以供參考:http://www.html5canvastutorials.com/tutorials/html5-canvas-line -width/ – Barudar

+0

恩,呃我非常愚蠢。謝謝。 –

相關問題