How do I make a global countdown?

Get help using Construct 2

Post » Tue Jul 01, 2014 3:07 am

Hello everyone!

I've been trying to make a countdown that stays constant through-out every layout switch and even when you leave the game. For example: a countdown that needs to wait 25 minutes before giving you an extra life. Right now I'm using the "Time Manager" plugin, I've managed to make the timer go down and then you gain a life but as soon as you leave the layout the timer resets.

Thanks for the help!
B
8
S
1
Posts: 32
Reputation: 437

Post » Tue Jul 01, 2014 7:11 pm

I don't know of any time related plugins, but an idea is to save the current time(real time) into webstorage and then when back in the game acess that value and compare to the new current time.
Please tag me with @caiorosisca if your post is refering to me :). I don't always follow the topics I answer.
B
11
S
4
G
1
Posts: 272
Reputation: 1,643

Post » Wed Jul 02, 2014 9:37 pm

Construct 2 has a "time" System Expression which is NOT reset when changing layouts and represents the number of seconds since the game loaded, so it would work between layouts put wouldn't persist if you leave the game.

I'm not sure there's an expression to get the actual time in Construct 2, but you could call a php and check the server time to get it. Thus you could store server timein a Webstorage object when closing the session and compare with server time next time you load the game. While the game is running I would use the time object, though, to minimize server traffic.
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
19
S
5
G
1
Posts: 512
Reputation: 2,689

Post » Mon Nov 03, 2014 5:42 am

@recksbayne

recksbayne wrote:Hello everyone!

I've been trying to make a countdown that stays constant through-out every layout switch and even when you leave the game. For example: a countdown that needs to wait 25 minutes before giving you an extra life. Right now I'm using the "Time Manager" plugin, I've managed to make the timer go down and then you gain a life but as soon as you leave the layout the timer resets.

Thanks for the help!


did you manage to make it work also when you quit the game? I am facing the same issue now.
B
5
S
1
Posts: 12
Reputation: 299

Post » Mon Nov 03, 2014 3:06 pm

What I did was use unix time and web storage, when you exit the game it saves the last unix timestamp so that when you launch the game again it can calculate it with the current unix time to figure out how much time has passed while the game was closed.

Sorry I'm not very good at explaining in detail but that's the gist of it, hope it helps!
B
8
S
1
Posts: 32
Reputation: 437

Post » Fri Jan 09, 2015 3:09 pm

@Lordshiva1948 answers how you can easily get the real time at this thread: viewtopic.php?f=147&t=121172
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
19
S
5
G
1
Posts: 512
Reputation: 2,689


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo and 26 guests