[solved]Not sure why this isn't working properly

0 favourites
  • 3 posts
  • I have added a bombing skill into my game that on key pressed Q with enough coins bombs spawn and shoot up the screen destroying enemies and asteroids on collision. I have a variable bombSkill that is set to 0, on key pressed is set to 1 and when bombSkill is set to 1 the bombs start to spawn.

    On the first Q keypress it works perfectly fine, when you hit it the second time only 2 or 3 bombs spawn, but then on the third press it works fine again. here is a screenshot of the code.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You have "Wait 7 seconds" inside of "Every random() seconds" loop, this can cause all kinds of problems..

    You basically start lots of delayed "set bombSkill=0" actions. When you press Q the second time, some of those delayed actions may still be running, that's why your bombing stops early.

    Try not to use long running "Waits" for tasks like this, use Timer behavior instead.

    On Q pressed
        Set bombSkill=1
        skillSpawn start Timer "StopBombing" for 7 seconds
    If bombSkill=1
        Every random(02, 04) seconds -> Spawn bombs
    skillSpawn On Timer "StopBombing"
       Set bombSkill=0
  • dop2000 awesome, thank you works like a charm

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