Disabling keys with global variables bug

0 favourites
  • 5 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • dropbox.com/s/thtzc3nb1r21q8r/Spacewarripoff.capx

    Hi Guys,

    I've been trying to set the spaceship controls so that it is only possible to fire after an interval so that spamming doesn't slow down/break the game.

    Using a global variable as a boolean to detect if the button has been pressed recently only seems to work occasionally which means that after the first interval has been reset, the game allows the player to spam fire again.

    You will find the events at the top of the controls group.

    Thanks!

  • How I've always gotten this to work is using a global something like this:

    On Key Pressed

    Global Variable 'Cooldown' set 'false'

    --------

    Set value 'Cooldown' to 'true'

    (Fire stuff here)

    Wait 0.5 seconds

    Set value 'Cooldown' to 'false'

    I'm away from my computer so I can't check C2 for exact verbiage, but that should work. A few things to note, if you use touch input or 'if key is down' add 'trigger once while true' to your conditions for something like this or you'll get strange problems sometimes for events such as this. Let me know if this way works for you.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Custom timers always worked for me..

    dl.dropbox.com/u/666574/bootsie%20-%20spacewarripoff.capx

  • Thanks Procrastinator, that works well now. The timer looks like a far more robust system.

    Thanks again guys, nice one.

  • The way you had it you'd need a trigger once condition in there:

    System: P2Fired = 1

    System: Trigger once

       -> System: Wait 0.7 seconds

       -> System: Set P2Fired to 0

    otherwise that event is running every tick for 0.7 seconds while P2Fired = 1. Then after 0.7 seconds all the delayed actions will run, setting P2Fired back to 0 for the next 0.7 seconds.

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