Countdown Progress Bar

yelmusleh

  • Posts: 26
Hello,

so I will try to make this as simple as possible. I am trying to create a timer in the form of a progress bar that will count down from 60 seconds.

I would like to be able to slow down the timer (maybe by .5 seconds) for five seconds by pressing a power up actor that will appear on scene randomly.

After five seconds, I would like the timer to resume at normal speed.

I already have the power up actor created.

How can I create a timer like this and how can I slow the time on it for five seconds?

Thanks in advance for your time!


Photon

  • Posts: 2693
Check this out:

http://photongamedev.wordpress.com/2013/06/03/the-do-after-dilemma-building-your-own-time-tracking-mechanic/

Using some creativity, you could use an attribute instead of a straight number for the decrement command and change that attribute as need be.
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

yelmusleh

  • Posts: 26
Thank you, I went ahead and took a look at it. Are these blocks that need to be downloaded? I am running Stencyl 2.0.

Photon

  • Posts: 2693
All the blocks I used can be accessed in Stencyl 2.0. Which blocks don't look familiar? Remember that some of those blocks are attribute blocks that you create in the attribute pane.
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

yelmusleh

  • Posts: 26
I am sorry about that, I realized that some were made, currently I have created both the Timer and the Countdown Attributes.

Since the timer is going to be visible, I am going to basically make it an actor, correct?

Thank you so much by the way, so far you have been a great help :)

Photon

  • Posts: 2693
You might want to consider putting it into a scene behavior. That way anything that needs to get to it (player, power-up) can get to it rather easily instead of having to track which actor it belongs to.
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

yelmusleh

  • Posts: 26
I got it working :D Thanks so much!

Now with this timer, I would like it to be visible to the player. This way the player can know how much time he/she has left before the level comes to a times up and starts all over.

Do you have another tutorial that can help with that?

Photon

  • Posts: 2693
Are we talking about strictly seconds or minutes and seconds (mm : ss display)?
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

yelmusleh

  • Posts: 26
We are talking specifically seconds, the timer would be set to 60, and then begin to count down from there.

An actor (the power up) should be able to alter the timer for 5 seconds.

Since I need to alter it, would the timer be an actor? or should I put the events specifically into the scene so that whenever the Power up pops up and is clicked it slows the timer for 5 seconds?

Photon

  • Posts: 2693
First, drawing text:

http://www.stencyl.com/help/view/drawing-text-and-huds/

Second, about manipulating the time: based on what I know, I would put it in a scene behavior for ease of access. There are a couple of ways you can manipulate attributes in a scene behavior...

1.) Add an event into the scene behavior that is triggered when the power-up is clicked: http://www.stencyl.com/help/viewArticle/148/
2.) Directly manipulate the decrement number attribute through the block found under Behavior >> Attributes in the palette.
3.) Make a Custom Block for your scene behavior that the power-up can call. I don't recommend this if you are still a beginner, but if you want to satisfy your curiosity: http://www.stencyl.com/help/view/creating-custom-blocks/
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

yelmusleh

  • Posts: 26
Hey Photon, so I went ahead and tried to create a custom Event that will allow for the timer to be altered but nothing seems to be working. Do you have any other possible suggestions that may help me create the Power Up?

I am anxiously awaiting your response thanks!

Photon

  • Posts: 2693
Can you post the code/behavior you are currently using please?
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

yelmusleh

  • Posts: 26
This is what I have done, I don't think it is right whatsoever...

Photon

  • Posts: 2693
OK, let's go back to square one: you said you had the timer by itself working, right? Revert back to that.

After that, start by making a new number attribute call Decrement Value. You'll want to set it to 1 initially and then use that in your "decrement countdown" block instead of the typed-in number (I noticed up there you are decrementing timer duration too; you should be decrementing countdown).

Now, you'll want a new event... that is, an event in the same behavior but not in the same event as your actual timer. It could be a collision event like "When Player hits actor of type Slow Down". When that triggers, you want to run something like this:

Kill Slow Down
Set Decrement Value to .5
Do After 5 Seconds:
    Set Decrement Value to 1


You don't want to have two separate timers like you have above. The point is to set up ONE timer, and then modify the attributes that the timer refers to in order to extend it/slow it down/etc.

Let me know if that helps.
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

yelmusleh

  • Posts: 26
It helped for sure... I still didn't make it work but it might be because I did something wrong. Attached are various screenshots of what I have done:

1) Clock button itself
2)Scene
3)Scene
4)Power Up