I'm wondering if I should switch my game over to requestAnimationFrame. If there even is still a reason to do so anymore, as I've read that setTimeout() now also pauses when you switch tabs in the major browsers.
Anyway, say I want to control the FPS of my animation.
Currently I can do it like this:
k.state.loopinterval =
window.setInterval(renderLoop(), 1000 / k.settings.engine.fps );
Where k.settings.engine.fps
is the wanted fps.
If I do it the requestAnimationFrame
way, I lose that possibility, and it'll just give me whatever it can give:
window.requestAnimFrame(k.operations.startLoop);
renderLoop();
I have seen some people suggest to place the requestAnimFrame in another loop:
setInterval( function () {
requestAnimationFrame( draw );
}, 1000 / 60 );
So... What should I go with? Leave it as it is?
What are the exact benefits of requestAnimationFrame, now that setTimeout is also paused when switching tabs?