Progress Bar Timer

OK GS Masters

I have another question on how to best and most efficiently handel a progress bar timer.

I would like to have a progress bar..lets say 5min. As time runs out the progress bar decreases...but also when the hero picks up items it will add time back to the bar.

I am currently using a progress bar for health (Jamie's Cross tutorial on progress Bars) What is the best way to make this happen with time..and adding time back in.

Thanks in advance

Comments

  • KevinCrossKevinCross London, UKMember Posts: 1,894

    It would be:

    timer bar width = (max width of timer bar / max time in seconds) * time left in seconds

  • quinn221quinn221 Member Posts: 280

    Thanks Guys!

  • quinn221quinn221 Member Posts: 280

    @timolapre1998 This is working great. Just one thing I have been trying to figure out. How to I cap the time, so lets say it will not go any higher than 30seconds and not lower than 0.

    I tried a few methods but could not get it to work....Any suggestions?

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    Use the min and max functions.

  • quinn221quinn221 Member Posts: 280

    @timolapre1998 @RThurman

    Hey Guys, I am little stumped on how the Time Bar example works. When I try to adjust it to my needs it will not work correctly.

    Let me explain in better detail what I am trying to accomplish. The game will have day and night cycles. Let say for example the day cycle is 10 min. The progress bar will get small every second or so. When the timer reaches 0, the night time cycle starts.

    The goal for the hero is to say in the daytime cycle as long as possible. This is done by picking up certain Items that will add time...but not to exceed the 10min mark.

    Once in the Night cycle the hero will have to pick up certain Items to get back into the day cycle....

    Any help would be greatly appreciated!

    Any idea how I can edit the example to make this work?

  • quinn221quinn221 Member Posts: 280
    edited June 2016

    Hey evermind...I got it working! Thanks

Sign In or Register to comment.