AndrewC

Advice please: best practice for timers/intervals

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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.