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

Get help using Construct 2

Post » Mon Jun 02, 2014 2:06 pm

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 :)

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
B
3
S
1
G
2
Posts: 8
Reputation: 916

Post » Mon Jun 02, 2014 2:09 pm

Have you tried altering the project settings ?
You do not have the required permissions to view the files attached to this post.
B
48
S
16
G
9
Posts: 1,097
Reputation: 11,195

Post » Mon Jun 02, 2014 2:11 pm

@Spongehammer, I have tried that , but it still pauses the game , I don't really understand why
B
3
S
1
G
2
Posts: 8
Reputation: 916

Post » Wed Jan 07, 2015 6:17 pm

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!
B
11
S
2
Posts: 19
Reputation: 889

Post » Wed Jan 07, 2015 8:36 pm

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.
Scirra Founder
B
395
S
232
G
88
Posts: 24,371
Reputation: 193,762

Post » Thu Jan 08, 2015 12:56 am

@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.
ImageImage
B
119
S
23
G
7
Posts: 1,070
Reputation: 12,989

Post » Thu Jan 08, 2015 1:18 pm

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.
Scirra Founder
B
395
S
232
G
88
Posts: 24,371
Reputation: 193,762

Post » Thu Jan 08, 2015 11:49 pm

@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.
ImageImage
B
119
S
23
G
7
Posts: 1,070
Reputation: 12,989

Post » Fri Jan 09, 2015 5:29 pm

GenkiGenga wrote: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.
Scirra Founder
B
395
S
232
G
88
Posts: 24,371
Reputation: 193,762

Post » Sat Jan 10, 2015 4:09 am

Ashley wrote: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.
ImageImage
B
119
S
23
G
7
Posts: 1,070
Reputation: 12,989

Next

Return to How do I....?

Who is online

Users browsing this forum: Lordshiva1948 and 59 guests