Jump to content

Pause and resume with disabled visibility change


elijahb
 Share

Recommended Posts

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

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

  • 3 years later...
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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...