0
我正在嘗試對演員的4個圖像進行動畫製作,但我所看到的只是一個圖像而沒有其他變化。顯示演員在動畫中隨時間變化的圖像
function init()
{
i=0;
while(i<ActStandX.length) //ActStandX holds the x locations of actor in a image spritesheet
{
for(var currentFrame=0;currentFrame<10;currentFrame++)
{
ctxBg.clearRect(0,0,800,600); //ctxBg is 2d context of canvas
ctxBg.drawImage(img,ActStandX[i],10,actWidth,actHeight,200,300,60,110);
}
i++;
}
requestAnimFrame(init);
}
我已經嘗試過這段代碼,但沒有成功。
您正在繪製每個圖像,而不會讓瀏覽器有機會在繪製每個圖像之間進行繪製。 – Shmiddty