I have a question about timing in Phaser using scene timers. Let’s say I have two events, A and B that should be 4 seconds apart. The code looks like this
this.scene.events.emit('eventA');
this.scene.time.addEvent({delay: 4000, loop: false,
callback: (event) => {this.scene.events.emit('eventB')}
)
so the event should take 4000 ms (4s). When I added the timers using performance.now()
after eventA and before eventB for a couple of times, I found that most of those were exactly 4s down to ms. However, other instances were off by around 16ms in either direction. I know that Phaser uses 60 fps making each frame last about 16.67ms. What happens was that a frame was missing (or added) in those instances where I got a difference of ~16ms.
My question: is there a way to force the update function to use a higher resolution timing when I create an event?
Thanks all for the help and support developing my games in Phaser!