How can I make a steady automata in JavaScript?
-
01-10-2019 - |
Question
I'm working on a javascript game and I've got an automata system controlling game time and sprite animation as well as giving a hand to the path finding system for timing and such. My problem is on slow browsers the javascript loop I'm using for counting the time is not very accurate. It tends to jump around a lot. I there a way to force the loop to run consistently at 30 fps?
Basically I need a way of keeping my automata loop running at 1/30th of a second.
Solution 2
It seems useing set interval instead of a self invoking function with setTimeout sped thing up quite a bit. thanks bobince
OTHER TIPS
There's no way for you to control the timing (have a read up here for more info), but without some more info I'm afraid I can't help you more.