elijahb

Pause and resume with disabled visibility change

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!

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.