Make the game run while not focused on

0 favourites
  • 13 posts
From the Asset Store
Run Vovan Run
$1.60 USD
60% off
Full game Construct 2 and Construct 3 to post on Google Play
  • Hi. How can I make my game still run while the game window/page/app is not focused on?

  • What isn't running?

    Anytime I change windows, I see all the sprites running around in the background. (In the preview window anyway)

    If you run games in the Scirra Arcade, they run just fine without focus too.

  • I turn on the remote preview mode and open my game on a tab, then open another tab. If I separate these two tabs on two windows, then resize them so that I can see both of them on screen, the game still runs while not being focused. However, if the blank tab takes full screen, the game is paused.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • OK, a couple of questions for clarity...

    1) What browser are you using?

    2) Can you walk us through the steps you are taking.

    For example, if I choose 'Remote Preview', I can't run the app locally UNLESS I open a new browser window, reload the project and run it again. (Fraught with danger having a project open in 2 windows IMHO).

    Using Chrome, I can open the two windows and it still runs fine locally. Using Chrome, I can EITHER have 'Preview Layout' OR 'Remote Preview' not both.

  • Hey all,

    Any update on this?

    The same is happening to me... if the app is minimized (unfocused), it simply stops running. Is there any way to make it run in the background (unfocused)?

    I read somewhere that I should add this line to the config.xml:

    <preference name="KeepRunning" value="true"/>

    I added but unfortunately, it didn't work (yet!!!)

    Does anyone know how to make the app keeps running when it is unfocused?

  • This is a chrome issue I think, where it tries to be more efficient by not running things that are tabbed out.

    Last I heard this does not apply to tabs with audio playing, so that was the workaround. You can use a short silent loop.

  • Have you tried the setting "Pause on unfocus"?

  • If all browser tabs/apps ran even in the background, it would absolutely hammer the battery life of the device. So operating systems and browsers are very strict about what can run in the background, for good reason: saving battery. Nobody wants an app to drain all their battery and many users will uninstall any apps they find wasting battery (and possibly give them a bad review).

    The question here is, what are you trying to do?

    If you want to play music in the background (e.g. music player app): you can enable playing in background on the Audio object.

    If you want to simulate real-world time passing in the game: wait until the app wakes up, measure how much time it was asleep for, and then simulate that much time passing. That has the same effect and doesn't waste loads of battery.

    If you want something else... what is it you're trying to do?

  • Ashley is correct, and this cannot be avoided.

    What you need to do is measure how much time has passed since the tab was last active, this you CAN do.

    From here, you simulate your game play. Which can be hard to do, but far from impossible.

  • If all browser tabs/apps ran even in the background, it would absolutely hammer the battery life of the device. So operating systems and browsers are very strict about what can run in the background, for good reason: saving battery. Nobody wants an app to drain all their battery and many users will uninstall any apps they find wasting battery (and possibly give them a bad review).

    The question here is, what are you trying to do?

    If you want to play music in the background (e.g. music player app): you can enable playing in background on the Audio object.

    If you want to simulate real-world time passing in the game: wait until the app wakes up, measure how much time it was asleep for, and then simulate that much time passing. That has the same effect and doesn't waste loads of battery.

    If you want something else... what is it you're trying to do?

    Thank you for your quick reply!

    What I am trying to do is to get the (lat, long) positions of the user and storing it in a database. Basically, I am trying to do the following:

    on location update -> AJAX passing lat, long parameters to MySql

    The problem is that I would like to know the trajectory of the user... to check if he did it right or wrong (according to the game rules). The user can reach the right final position but I cannot evaluate if s/he followed the right path.

    I do not need to call the ajax function on every location update if I can save it in a local file and submit it later. The point is that I need to record his trajectory and when the app is unfocused it stops getting users position.

    Is there any way to do it?

    Thanks a lot!

  • This is a chrome issue I think, where it tries to be more efficient by not running things that are tabbed out.

    Last I heard this does not apply to tabs with audio playing, so that was the workaround. You can use a short silent loop.

    Not sure if it is a chrome issue... From what I read iOS and Android simply put the app in pause state when it is not focused.

    Could you give me an example of how the silent loop would work to get gps location?

    Thanks a lot for your reply!

  • Have you tried the setting "Pause on unfocus"?

    What do you mean? Sorry didn’t get your tip...

    If I understood exactly what you said I want the opposite... I want to make the keep running avoiding the pause state.

    Thanks for your reply!

  • I am facing this same problem.

    My need is very specific - I need to be sure that any MULTIPLAYER HOST instance will run in the background if the browser tab is changed.

    The documentation says this should be automatic for any MULTIPLAYER HOST instance, but it's not working for me. Any host that I run will PAUSE when the browser tab is not active. This kills communications among all the peers.

    Anyone else see this? Anyone else solve this?

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