How do I find a way around "pause when unfocused"

0 favourites
  • 11 posts
From the Asset Store
Use this game pack to create your own game, modify the existing game or simply take a look and see how it was made.
  • Hi everyone! I'm working on a tamagochi-style game that really needs to be able to run when you don't have it's tab selected.

    I say it's tamagochi-like because it's a game where you basically take care of this little guy and try to keep him alive. In my game you are in charge of a little mercenary, and you can train him to improve different attributes, then send him on quests and hope he comes back alive.

    I have a small prototype I've started to make this thursday, but it already shows how the game works.

    https://dl.dropboxusercontent.com/u/798 ... index.html

    You can drag the character and drop him in any room so he will train an attribute / eat / sleep

    click on the paper on the wall to select a quest, and click on GO to get it started.

    As you can see, the game is somehow meant to be played a bit on the background, and for that to work, I need to find a way around the "pause when not focused" option. I want you to be able to leave your character to train his attack, then get back to facebook , or whatever you are doing, without pausing the game.

    Can anyone help me ? I hope I was clear enough about my problem <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    We have a lot of talented people here and I'm sure someone will be able to help me out.

    Thanks a lot, guys =D

  • Have you tried altering the project settings ?

  • spongehammer, I have tried that , but it still pauses the game , I don't really understand why

  • I have the same question. I've got a multiplayer game, and the HOST does not pause when unfocused... but the PEERS do, regardless of the settings mentioned above. Anyone know how to avoid this? I don't want peers to pause when unfocused. Thanks!

  • Everyone keeps asking this, and you really shouldn't allow the game to run in the background. It will end up hogging all the user's CPU and memory (remember how much people hated Flash when it did that), and on mobile it drains the battery.

    Just use the Browser object 'On suspend' and 'On resume' triggers to measure how long the game was suspended for, and then when it comes back, simulate that much time passing.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ashley

    Would it be possible to change this during runtime? That way if a player was in a lobby it could pause on unfocus saving resources while at the same time keeping the game playing when you needed it to.

    I agree with you that it is better to avoid using excess resources unnecessarily but to me its worth it if it means that my game wont break because someone wanted to quickly check their emails after they finished their turn.

    I could build an action queue and update all the actions when the player resumes but I would much rather it just work in the background.

  • Why would your game break because it suspended briefly as the user tabbed away?

    The best solution is to support the suspending that the engine already does and not let that break the game - I don't think there are any good excuses to drain battery, spin up laptop fans permanently, etc.

  • Ashley

    I have a card/board game in the works that is built to run off simple Multiplayer.Messages rather than relying on the host syncing objects. Its fairly robust as it is but when in a battle with another player, if too many messages are received when a peer is minimised it can break the game because the peer cant update all the changes at once.

    I could create an action queue to handle this so that when the player resumed, all the actions updated one after the other (and it would work) but it would end up slowing the game down as the resumed player waits for all the animations to run through (the player only needs to analyse what is currently on the board in order to make a move).

    If i had control over it during runtime I could set it so that the;

    * Title screen/lobby/deck editor is set to pause on unfocus.

    * In a battle where i expect the player to be actively playing the game anyway its set to do not pause on unfocus.

    I know that you are worried that people will abuse it and create inefficient games. In a worst case scenario for my game though, if a player minimises the screen in a battle and the game continues to run in the background, it will only continue to take resources until that player is kicked for inactivity (1 min approx) in which the game would be set back to 'pause on unfocused' and were back in the clear.

  • I could create an action queue to handle this so that when the player resumed, all the actions updated one after the other (and it would work) but it would end up slowing the game down as the resumed player waits for all the animations to run through (the player only needs to analyse what is currently on the board in order to make a move).

    I don't see any fundamental reason you have to make the player wait for all the animations. Surely you'd make a catch-up mode which works instantly instead of making them sit and wait?

    IIRC triggers still fire when suspended, so 'On received' etc. should still fire as messages come in. Also you could send messages in 'On suspended' and 'On resumed' to notify players you've gone AFK, so they know they won't be responding.

  • I don't see any fundamental reason you have to make the player wait for all the animations. Surely you'd make a catch-up mode which works instantly instead of making them sit and wait?

    IIRC triggers still fire when suspended, so 'On received' etc. should still fire as messages come in. Also you could send messages in 'On suspended' and 'On resumed' to notify players you've gone AFK, so they know they won't be responding.

    Ahh ok, I had assumed that peers wouldn't be able to receive messages until the browser resumed. My mistake!

    I have just added conditions on the messages received that check if the page is visible and if not the animations skip. Working perfectly.

    Thanks for your time Ashley.

  • I have the same question. I've got a multiplayer game, and the HOST does not pause when unfocused... but the PEERS do, regardless of the settings mentioned above. Anyone know how to avoid this? I don't want peers to pause when unfocused. Thanks!

    I have exact same problem.

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