How do I... spawn a sprite on key press and prevent another spawn until...

0 favourites
  • 3 posts
From the Asset Store
Random Maze Generator with Door & Key System - tutorial capx
  • Hi Community,

    I'm trying to spawn a sprite on key X press. I only want to press once and prevent another spawn until the sprite is distroyed...

    I'm trying to use a Timer on this and it ain't working.

    Player on layer... key X press - player spawns grenade sprite with bullet behavior.

    I only have 3 grenades and i want to prevent player from pressing X again until that grenade has exploded.

    I've tried Is On screen and Boolean, but I can't work it out.

    Help!

    Thanks,

    Roberto

  • Assuming the object is destroyed when it explodes you can do :

    on X pressed with condition global var=0 : action=spawn grenade and set global var=1

    on grenade destroyed: set global var=0

    The problem with that is you are counting on it to be destroyed and may come across bugs when it doesn't get destroyed or something.

    You can also use a timer if that is relevant :

    on X pressed with condition timer=0 (on another object not the grenade) : spawn grenade, start timer

    Note you can't use the object for timer condition, use system compare 2 values, object.timer.currenttime("timername")=0

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks soooo much plinkie,

    So this is what I interpreted from your reply:

    On key pressed

    System var=0 | spawn grenade

    | set var = 1

    Grenade bullet speed <=0 | grenade Destroy

    Grenade | On Destroy | Set var = 0

    and it works a treat!]

    Thanks again!

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