Cant Figure Out A Timer

Get help using Construct 2

Post » Thu Mar 07, 2013 6:28 am

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.
B
50
S
14
G
12
Posts: 813
Reputation: 16,764

Post » Thu Mar 07, 2013 6:39 am

why don't you put BuffTimer out, as an event?
and put a condition to activate it
B
18
S
5
G
4
Posts: 568
Reputation: 5,079

Post » Thu Mar 07, 2013 6:55 am

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?
B
50
S
14
G
12
Posts: 813
Reputation: 16,764

Post » Thu Mar 07, 2013 7:04 am

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.Tekniko2013-03-07 07:05:47
B
50
S
14
G
12
Posts: 813
Reputation: 16,764

Post » Thu Mar 07, 2013 7:05 am

Oh, found an easier way:
just add a reset action above each "System set BuffTimer to"
B
18
S
5
G
4
Posts: 568
Reputation: 5,079

Post » Thu Mar 07, 2013 7:43 am

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 :)vee412013-03-07 07:46:19
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Fri Mar 08, 2013 6:53 am

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.


and
Tekniko2013-03-08 06:54:16
B
50
S
14
G
12
Posts: 813
Reputation: 16,764

Post » Fri Mar 08, 2013 6:57 am

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
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Fri Mar 08, 2013 7:03 am

OMG, you are brilliant! I see what I was doing wrong there now. Thank you so much, works great!
B
50
S
14
G
12
Posts: 813
Reputation: 16,764


Return to How do I....?

Who is online

Users browsing this forum: LeFuji and 24 guests