quiphop Posted June 21, 2016 Share Posted June 21, 2016 Hi everyone. I have the looped timer : timer = this.game.time.create(false); timer.loop(Phaser.Timer.SECOND * 3, this.endTimer, this); timer.start(); Everything works good, but i want to play sound every ticked second, how to implement this? Link to comment Share on other sites More sharing options...
DevJ Posted June 21, 2016 Share Posted June 21, 2016 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. setInterval(function(){ yourSound.play(); }, 1000); Link to comment Share on other sites More sharing options...
quiphop Posted June 22, 2016 Author Share Posted June 22, 2016 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; } DevJ 1 Link to comment Share on other sites More sharing options...
Recommended Posts