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

Get help using Construct 2

Post » Tue Jul 29, 2014 8:25 am

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.
B
5
Posts: 21
Reputation: 267

Post » Tue Jul 29, 2014 9:57 am

simplification:

save the time and date

and on start compare the current time and date with the saved one..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Jul 29, 2014 1:23 pm

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? :)
B
5
Posts: 21
Reputation: 267

Post » Tue Jul 29, 2014 2:11 pm

@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.
B
14
S
2
G
1
Posts: 53
Reputation: 850

Post » Tue Jul 29, 2014 2:36 pm

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.
You do not have the required permissions to view the files attached to this post.
ImageImageImageImage
B
158
S
66
G
43
Posts: 2,603
Reputation: 35,868

Post » Tue Jul 29, 2014 3:14 pm

@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. :D

@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?

Image
B
5
Posts: 21
Reputation: 267

Post » Tue Jul 29, 2014 3:31 pm

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.
You do not have the required permissions to view the files attached to this post.
ImageImageImageImage
B
158
S
66
G
43
Posts: 2,603
Reputation: 35,868

Post » Tue Jul 29, 2014 5:23 pm

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.
B
5
Posts: 21
Reputation: 267

Post » Tue Jul 29, 2014 5:59 pm

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?
B
5
Posts: 21
Reputation: 267

Post » Tue Aug 05, 2014 11:02 am

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

:(
B
7
Posts: 3
Reputation: 297


Return to How do I....?

Who is online

Users browsing this forum: tarek2 and 22 guests