Possible input blocker?

I need a piece of code that says if one arrow key is already being held down, the other arrow keys will not work (The events assigned to them won't execute) until the one held down is released. Is it possible?

Answers

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited December 2014

    There's probably a simpler way but here's what I came up with. It's Mac Creator file so I've included a screenshot of one of the rules. For each arrow rule, just change the four places where it says "left" to "right" or "up" or "down." Note that self.keyPressed is a text attribute that starts out blank. The only bug I found was that if you press and hold an arrow, such as left, and then press another arrow such as up while still holding the left arrow, and then let go of the left arrow so that you are only pressing the up arrow, it doesn't recognize the next press of an arrow key. This is sort of like rocking back and forth on the keys... I'm sure it sounds confusing the way I described it!

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.