Disable Specific Keys

Game Editor comments and discussion.

Disable Specific Keys

Postby phyzix5761 » Wed Mar 09, 2011 9:15 pm

Is there a way to disable a specific key when an event takes place? For example, disabling left arrow when player presses right arrow.

Thank you!
phyzix5761
 
Posts: 261
Joined: Sun Feb 27, 2011 4:28 am
Score: 18 Give a positive score

Re: Disable Specific Keys

Postby Hblade » Wed Mar 09, 2011 9:32 pm

Yes, there is a way. If your using the KeyDown event, just use a variable :) Click variables, add, and make a variable called Keys. Click Array, click yes. Now however many keys you are using for the controls, put that number in the box + 1, so say your using like, 5 keys. you'd put 6 in the box. Now click okay, open up Notepad and write this down
Keys[0] = L (Or what ever key your using)
Keys[1] = A
Keys[2] = Etc...



Now, your almost done! :) before the code for your keydown event, make an if statement.
Code: Select all
If (Keys[0]==0) { //Your key was L in this case, as seen above
YOUR_CODE_HERE
}


Put the } at the very bottom of all of the code.





Now to disable and re-enabel that key, all you gotta do is call the variable. Example:
Code: Select all
//disable the key
Keys[0]=1;

//Enable the key
Keys[0]=0;


hope this helped :D
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Disable Specific Keys

Postby Hblade » Wed Mar 09, 2011 9:37 pm

If your trying to fix the moonwalk bug, there are many ways :) however I dont have any links at the time xD
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Disable Specific Keys

Postby phyzix5761 » Wed Mar 09, 2011 10:45 pm

Thanks for your response. I will test it later.

I fixed the moonwalk bug. This is for another bug. I want to allow the player to only walk in one direction at a time while still being able to use abilities/weapons.
phyzix5761
 
Posts: 261
Joined: Sun Feb 27, 2011 4:28 am
Score: 18 Give a positive score

Re: Disable Specific Keys

Postby schnellboot » Wed Mar 09, 2011 10:46 pm

why do you have to disable some keys then?
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron