Jump to content

Chaining multiple timer events


liorfrenkel
 Share

Recommended Posts

I ended up avoiding the repeat function and doing something like that:

var speedData = [
    {
        spawnInterval: 5000,
        spawnTimes: 2
    },
    {
        spawnInterval: 1000,
        spawnTimes: 5
    },
    etc...
]
var nextDuration = 0;
speedData.forEach((speedData) => {
    for (var i = 0; i < speedData.spawnTimes; i++) {
        this.timer.add(nextDuration, THE_CALLBACK, this);
        nextDuration += speedData.spawnInterval;
    }
}, this);

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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