Original Post
Hello!
I am creating a HTML5 game engine & I have a few questions regarding the game loop. Note: I'm not really looking for the most accuracy, nor do I care about compatibility. I'm looking for the best performance.
1. setinterval vs requestAnimationFrame? I understand the differences with regards to timing, but is there really a good argument to use setinterval over requestAnimationFrame?
2. I created a Timer class that uses one of the above methods [requestAnimationFrame for now] to call Timer.Tick() on a set FPS. I need Main.Draw() & Main.Update() to be called on each tick. Would performance take a hit if a "Tick Event" fired off each time the Timer.Tick() was called? Listeners would be set up in Main to listen for each "Tick Event" and fire off the Update/Draw function.
Thank you very much for any advice!
I am creating a HTML5 game engine & I have a few questions regarding the game loop. Note: I'm not really looking for the most accuracy, nor do I care about compatibility. I'm looking for the best performance.
1. setinterval vs requestAnimationFrame? I understand the differences with regards to timing, but is there really a good argument to use setinterval over requestAnimationFrame?
2. I created a Timer class that uses one of the above methods [requestAnimationFrame for now] to call Timer.Tick() on a set FPS. I need Main.Draw() & Main.Update() to be called on each tick. Would performance take a hit if a "Tick Event" fired off each time the Timer.Tick() was called? Listeners would be set up in Main to listen for each "Tick Event" and fire off the Update/Draw function.
Thank you very much for any advice!