我在较低的画布上使用它:
var requestAnimFrame = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.msRequestAnimationFrame ||
window.oRequestAnimationFrame ||
function(callback) {
window.setTimeout(callback, 1000/60);
};
我将它用于位于较低层之上的画布层:
function DrawSpawnAnimation() {
anim();
}
function anim() {
ctxAnimation.drawImage(spriteSheet, ExplodeFrame * 100, 2740,100,100,explodeX,explodeY,100,100);
if (ExplodeFrame < 5) {
ExplodeFrame++;
setTimeout(anim, 500);
}
//alert("Show current frame of animation"); - this shows the animation works, it just does
// not show it one frame per half second.
}
我的问题是动画在屏幕上以毫秒为单位闪烁。较低的画布刷新是否搞砸了?