Game pauses when switching browser tabs

0 favourites
From the Asset Store
Toggles Dials Switches and Alerts ! A foundational sound grouping of Analog type switches and Steampunk effects
  • "hi, i see a bug in the game. if i switch tabs in the browser, the game stops, stops running. only when i go back to the game tab, it continues. not good. the game needs to always run, even if i switch tabs"

    How to make the game keep running when the player switches the browser tab?

  • why does it need to run in the background when you switch tab ? most responses say you can't do this and you shouldn't do this.

  • It's an online space aviator crash game, so this should be running in the background at any cost. Any idea how to do it?

  • The problem is when switching tabs in the middle of the game the game is pausing, I don't want it to pause

  • It should pause though, I'm asking what you think it should be doing in the background while you are in another tab.

  • The game should keep running, that's what I need, as it's a crash game

    Is there any way to do this?

  • Everywhere I look even on outside forums it says suspending when switching tabs is expected and the only way around it is using hacky methods to override the browser, which isn't recommended.

  • I think Tatbarao might be trying to make an idle game or one of those games that relies on timers, like maybe those dragon breeding games? I'm not smart enough to know exactly how to do it, but if the game could store the real world time when a player leaves the tab, and then compare it to the time when they return, and then make changes based on that time difference, then it would kinda be like the game didn't pause.

  • Hi, that wouldn't be it, it would be a crash game. Have you ever played the Aviator Casino game? It's a real-time game, so the game shouldn't pause at any time.

  • I think Tatbarao might be trying to make an idle game or one of those games that relies on timers, like maybe those dragon breeding games? I'm not smart enough to know exactly how to do it, but if the game could store the real world time when a player leaves the tab, and then compare it to the time when they return, and then make changes based on that time difference, then it would kinda be like the game didn't pause.

    Nah it's some kind of real time casino game. If it was an idle game it is possible to do what you're saying by comparing time and I would've suggested this.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hi, that wouldn't be it, it would be a crash game. Have you ever played the Aviator Casino game? It's a real-time game, so the game shouldn't pause at any time.

    Casino games are complicated. One option maybe is to just show them the final result when they return after suspending the game, since many casino games use api with a known result and then display it to the player after.

  • Browsers basically forcibly suspend any content in the background to prevent them draining system resources and wasting battery. There isn't usually any way for web content to work around this.

    You can still make projects which seem to progress in the background though by using other workarounds - see the offline builder for one timer-based example that even works when the browser is entirely closed, and catch-up time which basically runs in fast-forward when you return to the tab. Either way you get the best of both worlds: it doesn't need to waste system resources while in the background, and it still looks and works as if it was running in the background.

  • Interesting everything that was said here... For example, I come across a problem where the host loses focus... I would like the Host to be able to resolve something in another tab but for the peers to continue playing normally, today if he presses alt+tab the information exchange freezes for everyone. ;(

  • Hi, that wouldn't be it, it would be a crash game. Have you ever played the Aviator Casino game? It's a real-time game, so the game shouldn't pause at any time.

    I don't gamble, so crash game means something completely different to me. I think the type of game is beside the point. The issue is the game pausing when switching tabs. Since the browser won't let you run the app when in a different tab, and you don't seem to want to fake it as I suggested, then how about just give the player a warning not to switch tabs?

  • I say this because I know it's possible since there are several games that don't pause when changing tabs and they are games in online parts like Crash Aviator. But maybe Ashley's solution will help a little.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)