Jump to content

How do I stop the game from pausing when player switches tabs?


gsus7125
 Share

Recommended Posts

In Phaser 2 it was just game.stage.disableVisibilityChange = true
But I can't find the solution in Phaser 3, does anyone know? I searched but could not find anything. Thanks.
It is a multiplayer game and one of the players updates everyone else on the state of the game so I can't have that player pausing.
Someone told me you can't even do that, but Phaser 2 had it so how can that be?

Link to comment
Share on other sites

You can't do it, and Phaser 2 can't do it either. It's entirely up to the browser if it thinks the tab is no longer active (i.e. switching away), so it will slow down, and then stop, any running scripts relying on setTimeout or raf, which in effect pauses your game. Phaser 3 actually never pauses automatically (aside from audio, the main loop never stops).

The solution is to capture when it happens and recover gracefully from it (just like you'd need to in v2, or any other framework)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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