How do I have timers stack properly?

  • 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.

  • 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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'll give it a try

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