kvazmatik Posted May 4, 2018 Share Posted May 4, 2018 Hello guys, I'm trying make timed event which will run in loop at random intervals. So I took some code from labs and modified it. function create () { timedEvent = this.time.addEvent({ delay: 1000, callback: onEvent, callbackScope: this}); } function onEvent () { timedEvent.reset({ delay: Phaser.Math.Between(100,5000), callback: onEvent, callbackScope: this, repeat: 1}); } This seems to work but I'm little bit confused why there needs to be repeat: 1, argument. Or it's just fine as it is. Link to comment Share on other sites More sharing options...
PyxelPranav Posted November 11, 2018 Share Posted November 11, 2018 Thanks for the help! I learned how to make timed events. You can include repeat like this btw - timedEvent = this.time.addEvent({ delay: 1000, callback: onEvent, callbackScope: this, repeat: 1}); For some reason, repeat: 1 repeats the events 2 times. repeat: 0 repeats it one time. Link to comment Share on other sites More sharing options...
Recommended Posts