franmcod Posted November 10, 2018 Share Posted November 10, 2018 Hey, i'm trying to count the time elapsed between the browser tab loses focus and when it gets back focus. I can't seem to find any example on how to do this for phaser3 Thanks in advance. Link to comment Share on other sites More sharing options...
Andrew Chen Posted November 22, 2018 Share Posted November 22, 2018 this.sys.game.events.on('hidden', function () { // game.scene.keys['GameScene'].sys.sleep(); var getLeavingTime = get leaving time here; }, this); this.sys.game.events.on('visible', function () { var getBackTime = get back time here; // game.scene.keys['GameScene'].sys.sleep(); game.scene.keys['GameScene'].sys.wake(); }, this); so the time elapsed is equal getBackTime - getLeavingTime Link to comment Share on other sites More sharing options...
Recommended Posts