Cant Figure Out A Timer

0 favourites
  • 9 posts
From the Asset Store
Tabata timer
$9.99 USD
Template for Tabata timer, fully documented in comments and video
  • My issue today is, this timer I am trying to use.

    Basically, when the player receives a buff I want it to last X amount of seconds. But, when a new buff is collected, the timer doesn't seem to go back to X and start counting down again... Here is what my code looks like.

    <img src="http://img839.imageshack.us/img839/1307/bufftimerbug.jpg" border="0" />

  • why don't you put BuffTimer out, as an event?

    and put a condition to activate it

  • Sorry, I have no idea what you mean. I mean I kind of do. But I am not sure how to call the other event.

    Paddle > On Collision with PowerUp : System Wait 5 seconds.

    How would I call this? You want me to use a function basically, right?

  • Okay, so I ran this through my head a couple times and I think this is what is happening.

    I am starting Timer A for Buff A and once its finished, it will set animation back to normal.

    BUT if Timer B for Buff B starts before Time A ends, then in effect, it starting a second timer. Even though I am using the same Global variable, the timer will only use the value at the time I called it. NOT continually re-checking said variable.

    That make sense?

    What I think I need to do is; add some sort of event that registers when a new buff has been received and in turn, cancels the previous timer.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Oh, found an easier way:

    just add a reset action above each "System set BuffTimer to"

  • I'd do it this way:

    Every 1 seconds

    BuffTimer > 0

    .. Subtract 1 from BuffTimer

    On collision with buff

    .. Set ball.animation to buff.animationVariable

    .. Set BuffTimer to 5

    BuffTimer = 0

    .. Set animation

    .. BuffTimer = -1

    You could have animationVariable in each buff that says the name of the variable it should change ball into, so you don't need separate events for each buff.

    EDIT. nevermind :)

  • I am still having issues. I tried it the way vee41 explained it... but I wasn't too sure what he/she meant. This is what I came up with.

    <img src="http://imageshack.us/a/img339/4789/0006b.png" border="0" />

    and

    <img src="http://imageshack.us/a/img825/43/0005p.png" border="0" />

  • Do paddle collisions like this and it should work (and you wont need to repeat same actions for every powerup type):

    Paddle On collision with PowerUp

    .. PowerUp animation SmallBall

    ...Ball set animation to Small

    .. PowerUp animation LargeBall

    ... Ball set animation to Large

    .. Add 50 to score

    .. Set BuffTimer to 5

    .. Powerup Destroy

  • OMG, you are brilliant! I see what I was doing wrong there now. Thank you so much, works great!

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