How do I add Lives on a timer of 30 minutes.

0 favourites
  • 10 posts
From the Asset Store
30 high-quality 2D monsters. This asset is perfect for a side scrolling game, or even a turn based RPG type game.
  • Hi,

    In my game, the player starts with 5 lives. Any time a life is lost, I want a timer of 30 minutes to start, at the end of which a life is added. Now I also want the timer to be active, even when the game is not being player. For example, if all the 5 lives are lost and the player exits the game and then comes back 3 hours later, he should be able to restart with 5 lives because he has been away longer than 5x30 minutes.

    I am trying to implement this using the Date plugin but can't seem to get anywhere.

    Any help will be very much appreciated. Thanks.

  • simplification:

    save the time and date

    and on start compare the current time and date with the saved one..

  • Thanks for your reply. Any chance you might point out how to subtract the time and date? For example, if the player stopped in 29.7.14 at 18.23 and came back at 31.07.14 as 02.12, then he should get 5 lives but how do I go about showing it?

  • priyanka19

    you could save each date in an extra array while splitting them up 1# (31|07|14) and 2# (29|07|14).

    Then you compare the spots of the array, starting from the very back. This wil result in many if and else clauses as you want to know which one is older and how much older but should be completly doable.

    same with the time.

  • i did exactly what you are asking some time ago with Date plugin - 5 lives and 30 minutes cooldown. It was very easy to set up and works really well.

    It was something like on the image below (can't share capx file, because it was a project for a client)

    Life have to number variables. start = 0 and length = 1800000 (30 minutes)

    And then I used simple webstorage to do some checks on start of layout if 30 minutes passed or not.

  • Gougth - Thanks for the idea of using arrays. That might just be what I am looking for. It's a really great idea. But it appears to be a lot of work. Oh well.

    shinkan - Yours is a very nice way to do a Countdown. Really like it. I just came across a capx that made the Countdown in the following way. My question is which one is better for performance on mobile devices?

  • First of all if you want to display text all the time - do not use Text object, use Spritefont instead. For the performance question... they are both the same probably.

    The question is, do you need to show countdown text all the time?

    Image below shows how I displayed 30 minutes countdown - just minutes without seconds, it looked liked this in game "30m", "17m" etc.

    and i used Text object because this was shown only in two specific places in the game and it updates once a minute (and only while visible). For most of the game time this was destroyed. On game over screen it was created, time was compared and then displayed.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for your quick reply.

    Yes, in the actual game, I plan on using Spritefonts (so much more flexible and of course, better performance). This is just for testing purposes.

    The countdown will be shown anytime the number of lives dips below 5. I think seconds are kind of important from a visual POV - having them gives a sensation (at least to me) of time passing by quickly, which in turn may be good to keep a player from giving up and walking away.

  • Okay, I think I found a way to solve my problem - by using UnixTimeStamp retrieved by using the Date plug-in. Now I have never had to use it - can anyone confirm that it is okay to work with the fairly large number that UnixTimeStamp is going to retrieve?

  • shinkan

    I'm near to finish my first game and i really need to fix this question,but reading this post i can't couse many steps are missing....... could you plz explain the various step you did to make it???? I will tnk you forever!!!!!

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