2017-04-12 8 views
0

私はバウンスボールプログラムを作っています。 壁を描いて壁の線幅を設定したい。 壁の線幅を設定するために、「ctx.linewidth = 30;」を追加しました。つまり、私のコードでは と書かれています。 しかし何も起こりませんでした。 私はlinewidthで私がctx.linewidth = 50を変更したことにとても驚いていました。 まだ何も起こりませんでした。 壁の線幅を設定する方法は?なぜ線幅が設定されていないのですか?

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'ない'参照のために実際に – Blindman67

答えて

1

あなたのの3行目の機能はctx.lineWidthなくctx.linewidthことになっています。 http://www.html5canvastutorials.com/tutorials/html5-canvas-line:資本W.

+0

W資本金ctx.linewidth'、と

-width/ – Barudar

+0

ええと、私は非常に馬鹿です。ありがとうございました。 –

関連する問題