I'm using Phaser.io
I'm making a simple game. I want my 'enemies' to fall from the top of the screen:
const enemies = this.physics.add.group();
function enemyGen(){
const xCoord = Math.random()*gameState.w;
enemies.create(xCoord, 10, 'enemy');
}
const enemyGenLoop = this.time.addEvent({
callback: enemyGen,
delay: ......,
callbackScope: this,
loop: true
})
I would like to decrease the delay when a player reach a certain score (which is stored in gameState.score).
I was thinking about having a variable stored in gameState.delay and then updating it from update(). The problem is that even if the gameState.delay is changed the addEvent still uses the previous value of gameState.delay.