Jump to content

Advice please: best practice for timers/intervals


AndrewC
 Share

Recommended Posts

Hi All,

I've seen discussions about the use of timers for control of timed repetition, and examples that use Phaser.time as well as others that use the setInterval mechanism. My question is - is there a best practice recommendation on which way is better?  

In my situation, I require the use of intervals in order to move a character sprite along a predefined path (generated by A*).  There appear to be a number of different ways to do this, and the interpolation function popped up during my research as well.  I'm keen to find out the trade offs and decision making involved by folks, and whether there is a recognised or standard best way to do it.

Kind Regards,

Andrew.

Link to comment
Share on other sites

Update: I may have partially answered my own question, after finding this comment on StackOverflow by Matthew Cooley:

"the reason to not use the native setTimeout in Phaser is that Phaser's timers are tied to its game loop, so for example if you pause the game it pauses all the timers automatically"

https://stackoverflow.com/questions/26319846/how-to-delay-the-start-time-of-a-timer-in-javascript-phaser

Would love to hear any further wisdom that folks could share.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...