Jump to content

Game stopps on tab switching


joerrey
 Share

Recommended Posts

Hey, i need my game to run all the time, even when the window/tab looses focus. So i used 

this.stage.disableVisibilityChange = true;

but it doesn't work properly. If I select a new Browser window, the game continues as intended. But if I switch the tab in the same window, the game pauses.

 

Is there a way to ensure that my game won't stop by switching the tab? 

Link to comment
Share on other sites

Phaser ties the running of update() to requestAnimationFrame() when it is available. The point of requestAnimationFrame is not just to try to target the optimal refresh rate, but to not draw when your game can not be seen. In addition to the issues discussed here: http://www.html5gamedevs.com/topic/9425-gametime-depends-on-the-monitor-refresh-rate/ you might have to consider using timers to periodically check the elapsed time and if it is larger than some value run your update function with the renderer mode set to  Phaser.HEADLESS

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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