How do I run game continuity at browser minimize?

Get help using Construct 2

Post » Fri Sep 23, 2011 9:59 am

The game is paused when browse minimize or switch to other web page. How do I run the game continuity in these cases?rexrainbow2011-09-23 10:02:17
B
97
S
22
G
178
Posts: 4,118
Reputation: 104,043

Post » Fri Sep 23, 2011 2:25 pm

You can't - browsers deliberately stop running hidden web pages to reduce CPU usage and save battery life on mobile devices. I don't think it's possible to work around, sorry.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Fri Sep 23, 2011 3:02 pm

I think a trick you can use is to store the time 5 seconds (so you don't need to know when the browser is stopped), then when the game resumes and the time saved is greater than 5 seconds, you can speed things up to how they would be if the game kept running.

Although, this would only be good for sim and RTS games probably.
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Fri Sep 23, 2011 3:42 pm

On the other hand, it's irritating as a player to switch the tab away, and come back and you've died because the game carried on while you weren't looking. IMO, it's actually a useful feature it pauses while you're not looking.

The player can always create a new window with a single tab - that might work to keep it running.Ashley2011-09-23 15:42:54
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Fri Sep 23, 2011 5:59 pm

[QUOTE=Ashley] On the other hand, it's irritating as a player to switch the tab away, and come back and you've died because the game carried on while you weren't looking. IMO, it's actually a useful feature it pauses while you're not looking.

The player can always create a new window with a single tab - that might work to keep it running.[/QUOTE]

Yeah, dying while away is lame. I was thinking of sim games like Smurfs where it says "Building complete in 2 hours".
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Fri Sep 23, 2011 7:32 pm

In that case, I guess you could compare the actual time when the building start to be built and set the finishing time to that starting time + building time.

That way doesn't matter if the game pauses or not.

But keep in mind that players could cheat changing their own pc clock.
If you could compare to a web clock somewhere, this would be avoided.


Anyway, it's just an idea.
B
50
S
16
G
7
Posts: 59
Reputation: 6,365

Post » Tue Nov 08, 2011 5:31 am

[code]+System:Every tick
- Text: Set text to time[/code]

I test this problem again in r65.

Chrome: paused when browser minimize.
Firefox: still running.
B
97
S
22
G
178
Posts: 4,118
Reputation: 104,043

Post » Tue Nov 08, 2011 1:34 pm

I think Chrome pauses, and Firefox starts running one tick every second (1 fps) to give the app a chance to stay up to date. For games it's not very useful though - in the latest releases of C2, if it spots it's going at 1 FPS it sets dt to 0, effectively pausing the game (so long as your game is framerate independent).Ashley2011-11-08 13:35:04
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580


Return to How do I....?

Who is online

Users browsing this forum: Matthew de and 20 guests