"Every x sec" not advancing when app not in focus

Get help using Construct 2

Post » Tue Jun 05, 2012 5:19 am

Hey all,

I am looking to disable a button for 10 seconds using the "Every x seconds" to decrement an integer that shows how many seconds are left and when it gets to 0 enables the button again.

The problem I am having is that if I click the button and disable it, then go to another tab in my browser like to check the email, then come back to the tab, it hasn't advanced since I went to the other tab.

How do I get it to keep counting in my "absence"?

Thanks so much! This is such a great community hopefully somebody can point me in the right direction.
B
4
Posts: 6
Reputation: 487

Post » Tue Jun 05, 2012 5:28 am

Try adding "Every tick" as a condition or use a global variable and add +1 every second or every tick.
Zelda Gamekit (my project)

Example capxs I have made:
Zelda-Style Inventory
Zelda Hearts System

The unwritten "How do I" capx etiquette! Nearly always provide a capx of the problem you have, and try to isolate the problem and/or no capx above 10 MB. :)
B
38
S
19
G
26
Posts: 438
Reputation: 16,581

Post » Tue Jun 05, 2012 10:57 am

@aaroncrunch

by using system wallclocktime

it gives the realtime seconds the app has been running

by saving this time when button is clicked you can compare how much time has been passed, and will work in "sleep" modus

i made a quick example

example
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Wed Jun 06, 2012 1:42 pm

The game is deliberately paused when you switch tab or minimise the window. @vtrix's solution is the only way around that.
Scirra Founder
B
359
S
214
G
72
Posts: 22,951
Reputation: 178,578

Post » Sat Jun 09, 2012 11:25 pm

Sorry I got hung up on some other projects for a bit but thanks so much for shedding some light on this! Should be able to solve my problem with this insight!

What a great community and tool!
B
4
Posts: 6
Reputation: 487


Return to How do I....?

Who is online

Users browsing this forum: austinblackbelt, Matthew de, Skebab, spcsmrf and 5 guests