How to make a Timer Bar

0 favourites
  • 11 posts
From the Asset Store
Health, Weapon & Rage Bars for your Games. Easy to use & Customize.
  • 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!

  • 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

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

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

  • Thank you so much Nimtrix! <img src="smileys/smiley1.gif" border="0" align="middle" />

    Edit: just to confirm, it worked like charm. Thanks, now I'm reading up on delta-time..!

  • hope you read more and learn more ^^

  • Try Construct 3

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

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

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

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

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

  • Great idea, LittleStan. Worked like a charm.

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