0
我正嘗試使用畫布和請求動畫框架在給定點集內創建一個圓。使用請求動畫框在畫布中設置一個圓圈
對於我已經使用一個功能象下面這樣:
function animloop(){
while(ny > pipeEnds.y) {
ctx.clearRect(0, 0, w, h);
drawCircle(nx, ny);
ny--;
nx = nx;
}
requestAnimFrame(animloop);
}
animloop();
function drawCircle(cx, cy){
ctx.beginPath();
ctx.arc(cx, cy, 2, 0, 2 * Math.PI, false);
ctx.fillStyle = "black";
ctx.fill();
ctx.closePath();
}
給定的一組點內的圓移動,但動畫不能看到。 當頁面加載圓到達最終位置時。
該代碼可以查看in this fiddle。
工作!謝謝你的好解釋.. – Adidev