Jump to content

detect visibility change without pause


Areg
 Share

Recommended Posts

I want to detect the visibility change in my game ( that is, when , for instance, browser tab loses focus, for example). I know that when that occurs, Phaser automatically pauses my whole game system. I want to prevent that automatic pausing, but still I want to receive signal/event  about this visibility change. 

Link to comment
Share on other sites

If this is a critical production feature you could hack the source a  bit for now until someones points out the correct way to do so.

Look at phaser.js .

Comment out line 20136 and line 20151 ( this.gamePaused(event); and this.gameResumed(event) ; and then go to line

16449, cut the  

 if (this.disableVisibilityChange)    {        return;    }

and paste it above this located at line 16468

  if (document.hidden || document.mozHidden || document.msHidden || document.webkitHidden)    {        this.game.gamePaused(event);    }    else    {        this.game.gameResumed(event);    }

This should fire the onBlur and Onfocus events with disableVisibilityChange=true .

 

Test it and let me know. Keep in mind that this is a BAD approach. You should keep your eyes in this thread for someone with a better solution.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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