Keyboard Commands Logic Issue

0 favourites
  • 3 posts
From the Asset Store
100 items casual and logic games. All icons are of a high quality.
  • Hello guys! This problem is not technical as much as it is logical, yet I can't seem to wrap my head around how to code (use the event sheet) to get my desired result.

    The player will have to press and hold a certain pattern and amount of keys in order to do an attack, after the attack has been done the player needs to repeat the sequence in order to do the attack again.

    Here is a couple of examples I have made that come close to what I want it to be like (you should see why being able to reset the sequence is important to not make the game unfair)

    Example 1:

    LINK: h.ttps://

    CAPX: h.ttps://

    Example 2:

    LINK: h.ttps://

    CAPX: h.ttps://

    (I think I've uploaded the right files correctly)


    Hold in this order (F + S + H + D + L)

    You can hold (F + S + H + D) and then tap L in both versions, I do NOT want the game to be like this, rather the opposite, that the player keeps repeating the sequence since I plan on adding different attacks (I hope by playing it makes my issue make more sense, I might be over explaining it :P)

    Thank you in advance for checking it out, if you don't have time to download and check the event sheet then the LINK is the straight up game so far so yeah!

  • Remember that each of the events is actioned every tick. So, if the F key is held down for one second the value of the Attack variable will be 60 - add a text object to display the Attack and you'll see what I mean...

    Your logic assumes that each of the events will behave a bit like a trigger so you need to figure a way to log if the keys are pressed in the correct order - I suggest using either a variable for each key being held down (testing that the previous key is down first) or an array and then making a test of those parameters.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Oh I've been so blind!

    Thank you for your reply, I'm now using a combination of variables (I might change it for an array when I implement more attacks) and I also figured out I could use both "On key pressed" and "On key released" to track if the player is holding the key down or not, without making the variable fly off the charts when its increased :P

    I would post links but it's quite difficult as a new user to the forum, thank you for your help though! :)

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