I’m working on my first HTML5 game. I use requestAnimationFrame to draw to the canvas, which is this:
window.requestAnimationFrame = function(){
return (
window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(/* function */ callback){
window.setTimeout(callback, 1000 / 60);
}
);
}();
I’ve only been using it in Chrome, but just now I tried it in Firefox. The game is laggy and not very smooth. Is this a bug, or is there a way I can fix this? Thanks in advance!
EDIT: Here’s the game: http://jackscode.99k.org/comets/comets.html
I don’t see your code so it’s hard to know what’s the way to fix it but maybe if you are using a lot of settimeout in your game try using delta time it so much faster, works like a charm for me. Check out this guide how he uses it http://buildnewgames.com/sprite-animation/