2012-10-11 48 views

回答

9

你開始你的畫線之前,請撥打beginPath()

function drawX(x, y) { 
    ctx.beginPath(); 

    ctx.moveTo(x - 20, y - 20); 
    ctx.lineTo(x + 20, y + 20); 

    ctx.moveTo(x + 20, y - 20); 
    ctx.lineTo(x - 20, y + 20); 
    ctx.stroke(); 
} 

更新後的代碼上的jsfiddle:http://jsfiddle.net/h4JvJ/23/

+1

尼斯的答案,@Stefan。 –

+0

非常感謝,您的指導幫助我節省了大量時間進行調試:(( –