I’m porting a project from P2 to P3.
In P2, the code triggered a timed event to happen as follows:
tick: function(){
var count;
var snd = new Audio(“mysound.mp3”);
snd.play();
// time between events is needed and follows exponential distribution
var next = - Math.log(1 - Math.random()) / this.lambda;
//loop the sound to re-trigger
game.time.events.add(next* 1000, function(){this.tick(count+1);}, this);
},
I’m having trouble with the event timer in P3. I keep getting an errorr, “cannot read property ‘time’ of undefined” for let timer = this.time.addEvent({…});