How do I have timers stack properly?

Just started using Construct 2? Post your questions here

Post » Sun Feb 28, 2016 2:34 pm

I have made a "pop the bubbles game" where the player has to tap on balloons that float up from the bottom of the screen. I have created a powerup that temporarily slows the balloons down but it doesn't stack properly.

The way it works is:
  • There is a variable BalloonSpeed that controls the velocity of the balloons
  • When a player touches a 'slow time' powerup
    • The current BalloonSpeed value is copied to a tmpBalloonSpeed variable
    • The BalloonSpeed value is reduced
    • An external sprite objPowerupTimer with a Timer behavior starts a new 5 second timer tagged 'slowtime'
  • When the 'slowtime' timer expires the tmpBalloonSpeed value is copied back to BalloonSpeed to restore the original speed.

This works as intended if the player hits a single 'slowtime' powerup but my problem is if the player hits another one before the speed resets the original speed is never restored. I have debugged the layout and the timer itself does reset but it is as if the On Timer event doesn't fire afterward.

Image
Image
B
4
Posts: 10
Reputation: 222

Post » Mon Feb 29, 2016 5:25 am

I would recommend limiting how often the player uses the "slowtime" powerup by creating an instance variable that checks to see if power up is active.

when obj_balloon is animation "ID_SlowTime" is playing | (do things) and set "powerup_active" = 1

if obj_powerup on timer "slow time"
and "Powerup_active" = 0

set balloon speed to....
set bullet speed to ....
set powerup active = 0

Give it a go and see if that works :)
B
8
S
1
Posts: 46
Reputation: 544

Post » Mon Feb 29, 2016 10:55 am

I'll give it a try
B
4
Posts: 10
Reputation: 222


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 8 guests