I am pretty new to Phaser 3, but I general problem I have been having is timed events getting backed up when someone tabs away on their browser. When they tab back, every event that would have triggered while they were on a different tab triggers at once. Is there a way to get these events to continue triggering while tabbed away? If not is there a way to detect tabbing away to pause the game or something? Thank you for any suggestions.
If you can post some code, that would be helpful. I have zero idea how it works because there are no examples floating around on Phaser 3 events when it comes to: https://photonstorm.github.io/phaser3-docs/Phaser.Core.Events.html#event:VISIBLE__anchor
I assume many are in the same predicament. Even the wrong answer is better than no answer.
I actually figured out how to do it properly so it didn’t back up! Simplifying and playing with it awhile from scratch worked out.
Running Test:
https://www.quintisgames.com/phaserTimerTest/phaserTimerTest.html
Core code:
var timer = this.time.addEvent({
delay: 500,
callback: addFaller,
callbackScope: this,
loop: true
});
function addFaller(){…}
I was going to put in a file download as well, but I can’t since I am a new user so you can go here for the zip (It will auto-download and redirect here):
https://www.quintisgames.com/phaserTimerTest/download.html
I see what you mean now, I think this is the correct solution as setInterval and recursive calls have some unintended side effects.
I am having a slightly different problem in that when it returns, I can’t get it to not play anything if the action was paused for more than a few seconds. I thought that might be the struggle, and I have no answer for this yet.