0 Favourites

How do I make a global countdown?

  • 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!

  • 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.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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.

  • recksbayne

    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.

  • 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!

  • Lordshiva1948 answers how you can easily get the real time at this thread:

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)