Jump to content

Looped Timer with action every second?


Recommended Posts

Use a simple setInterval to loop your sound. It'll play every 1000ms. To stop playing the sound, use clearInterval. Note that you might have to set your looping parameter to false when you add the sound to the game.

}, 1000);


Link to comment
Share on other sites

Thanks @DevJ, but i found better solution based on time delta (thanks to @Str1ngS);
So, At the start of game i'm create a variable of current time

var tick = game.time.now;

Then at the update func. i'm checking the time delta
var tick = this.game.time.now;

if (game.time.now - tick > 100) {
 tick = game.time.now;


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

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.


  • Recently Browsing   0 members

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