elijahb Posted February 6, 2016 Share Posted February 6, 2016 Hi, I'm totally new building games and started a small project using phaser. I've seen that on page blur or tab switch the game stops, and looking for this I've found about the disableVisibilityChange option to keep the game running. Since this only works if the page is still being displayed (without focus), I added events for onPause and onResume to rearrange the game when the page focus is back. But I've encountered that when setting disableVisibilityChange = true, events onPause and onResume don't work, even that the game is paused when switching tabs. I'm missing something? How can I get events onPause and onResume to work, and at the same time keep the game running when it's still visible but without focus? Thanks! Link to comment Share on other sites More sharing options...
Zeterain Posted February 9, 2016 Share Posted February 9, 2016 If I understand correctly, the issue you are experiencing is: After setting disableVisibilityChange to true, onPause and onResume do not fire when switching tabs. To quote the Phaser docs for disableVisibilityChange (http://phaser.io/docs/2.4.2/Phaser.Stage.html#disableVisibilityChange): Quote By default if the browser tab loses focus the game will pause. You can stop that behaviour by setting this property to true. When you have disableVisibilityChange set to true, the game will not pause after losing focus, and will therefore not fire the onPause event. Because the game is never paused, it is also never resumed, which is why onResume doesn't fire either. Let me know if I misunderstood the problem or if this didn't solve the issue. Link to comment Share on other sites More sharing options...
Kristiyan Posted August 29, 2019 Share Posted August 29, 2019 On 2/9/2016 at 7:09 PM, Zeterain said: If I understand correctly, the issue you are experiencing is: After setting disableVisibilityChange to true, onPause and onResume do not fire when switching tabs. To quote the Phaser docs for disableVisibilityChange (http://phaser.io/docs/2.4.2/Phaser.Stage.html#disableVisibilityChange? When you have disableVisibilityChange set to true, the game will not pause after losing focus, and will therefore not fire the onPause event. Because the game is never paused, it is also never resumed, which is why onResume doesn't fire either. Let me know if I misunderstood the problem or if this didn't solve the issue. and so, is there a solution to trigger onPause and onResume in this situation when disbleVisibilityChange = true? Link to comment Share on other sites More sharing options...
Recommended Posts