You are reading a single comment by @Owen and its replies. Click here to read the full conversation.
  • Hello,
    What is the best method for frame based animations/games to get accurate FPS?
    The two methods I've tried are:

    setInterval(tick, 1000 / 30);
    

    This works well but if the tick() function ever takes longer than the interval time they can begin to stack up on one another.

    The second method I've tried is setTimeout from within the tick() function. The only problem I have here is the FPS drop a lot as each frame is tick() excuse time + frame timeout.

    function tick() {
      setTimeout(tick, 1000 / 30);
    }
    tick();
    

    Are there any other methods I can look at, like using the system time to decide when to next call tick()?

About

Avatar for Owen @Owen started