How to make a Timer Bar

Get help using Construct 2

Post » Thu Jun 28, 2012 10:00 am

Hi,

I am new to Construct 2 (I used to work on Game Maker) and this forum! C2 have left a good first-impression on me so far.

I want to create a Timer bar, which gradually reduces.

Like this:
||||||||          15 secs left
|||||            10 secs left
|||              5 secs left
|             1 secs left
TIME UP!

Getting an Apple will reset the timer, so in order for the player to win, he have to get an apple every 15 seconds.

Is there a way to make this work? I'd be glad if you could send me example .capx, it'll aid in the learning process!thesecretweapon2012-06-28 10:01:53
B
10
S
2
Posts: 79
Reputation: 1,122

Post » Thu Jun 28, 2012 10:19 am

check this link its hard the same idea you wanted ^^ just change it from lifes to time (dt) or you can use every x second subtract 1 from global... and when you eat apple add to global...
(from Kiyoshi)
http://www.scirra.com/tutorials/182/making-a-fancy-lifebar
B
48
S
15
G
6
Posts: 795
Reputation: 12,035

Post » Thu Jun 28, 2012 10:57 am

Thanks! It's doing what it's supposed to do! :)

But I want the bar to respond to the time remaining not player's life. How do I make a timer of say 15 seconds and the bar to reduce it's width according to the time remaining.
B
10
S
2
Posts: 79
Reputation: 1,122

Post » Thu Jun 28, 2012 2:19 pm

Here's an example for you, hope it helps:

TimeBar.capx (r95)

PS: Read the tutorial about delta-time and framerate independence if you wonder how the 'dt' expression works.
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Thu Jun 28, 2012 4:22 pm

Thank you so much Nimtrix!

Edit: just to confirm, it worked like charm. Thanks, now I'm reading up on delta-time..! thesecretweapon2012-06-28 18:51:06
B
10
S
2
Posts: 79
Reputation: 1,122

Post » Thu Jun 28, 2012 7:13 pm

hope you read more and learn more ^^
B
48
S
15
G
6
Posts: 795
Reputation: 12,035

Post » Wed Oct 02, 2013 1:01 pm

Sorry if reopen this thread is not ok, but I thought that my issue will complement it. How to make the time bar to start after a second or more? Thank you.RenatoB2013-10-02 13:13:55
B
65
S
13
G
2
Posts: 969
Reputation: 6,732

Post » Wed Oct 02, 2013 1:16 pm

Because this is an old thread, it was made before Construct2 had the timer-behaviour, which makes implementation of timers much easier.

But to answer your question without looking at the capx, you would probably just put a system wait action before the timer actions.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
53
S
16
G
8
Posts: 6,157
Reputation: 19,744

Post » Thu Oct 03, 2013 1:37 pm

Hi LittleStain. I-m using the script that nimtrix provided, with "every tick" condition. I tried do use "on load" condition with "wait" action, but not work.
B
65
S
13
G
2
Posts: 969
Reputation: 6,732

Post » Thu Oct 03, 2013 2:40 pm

@RenatoB

Put all the code that has to do with the timer in a group called timer and disable active on start for that group.

add system wait 2 seconds and system set group active "timer to On start of layout.

That will work.

You could also use a start button to start the whole timer thing when button is touched, just set the group active when you need it. LittleStain2013-10-03 14:41:57
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
53
S
16
G
8
Posts: 6,157
Reputation: 19,744

Next

Return to How do I....?

Who is online

Users browsing this forum: DiabloOvermind, emoticon, odiusfly and 17 guests