Timer run in background

Get help using Construct 2

Post » Wed Jun 07, 2017 1:06 pm

Hey but so you can do this thing ie create a countdown similar to clash of clans? But without using a server. I would like to do for example that I touch a button and I get a write with a countdown for example 15:00 minutes and if I close the application for 10:00 minutes and return it to me it appears that 5:00 minutes remain to complete this action I do not know If I explain it ..
B
13
S
5
Posts: 17
Reputation: 963

Post » Wed Jun 07, 2017 1:57 pm

Yes. What I've shown is probably the simplest method. You would just need to save the length of the original countdown(15 minutes) to local storage.
Other methods might include the timer behavior using the save slot feature.
Image ImageImage
B
168
S
50
G
164
Posts: 8,236
Reputation: 105,591

Post » Thu Jun 08, 2017 9:43 am

I wrote this way (My Timer background) and it works only when I leave the app but when it does not resume within the timer .. and when it reaches 0 continues and goes below 0. How can I make it appear that is written in this way? 15: 00 instead of 900.00? And that when the timer gets zero it stops and can you connect the classic timer with the backgroun timer?

--- Classic timer ---

{System.every tick: set text to floor floor (Timer / 60% 60) & ":" & floor (Timer% 60)
System.Timer> 0: System subbtract dt from Timer
System.Timer <0: system set Timer to 0
}

--- My Timer background ---
{System: on start layout: local storage: check item "mytimer exist;
LocalStorage: on item "mytimer" exist: localStorage: get item "mytimer";
LocalStorage: on item "mytimer" get: text: set text to (15 * 60) - ((Date.UnixTimestamp-LocalStorage.ItemValue) * 0.001);
Button: on clicked: LocalStorage: Set item: Setitem "mytimer" to Date.UnixTimestamp;
LocalStorage: On item "mytimer" set: text: Set text to "Timer set".
B
13
S
5
Posts: 17
Reputation: 963

Previous

Return to How do I....?

Who is online

Users browsing this forum: imothep85, KTML5 and 9 guests