Sign in to follow this  

Looped Timer with action every second?

Recommended Posts

Hi everyone.

I have the looped timer :

timer =;
timer.loop(Phaser.Timer.SECOND * 3, this.endTimer, this);

Everything works good, but i want to play sound every ticked second, how to implement this?

Share this post

Link to post
Share on other sites

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);


Share this post

Link to post
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 =;

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

if ( - tick > 100) {
 tick =;


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.

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.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.