disable keydown events

Non-platform specific questions.

disable keydown events

Postby yourownskill01 » Mon Apr 29, 2013 9:50 pm

I am trying to disable a keydownevent of the key K when I collide with an Actor...but I am not sure how to do this...all I found was disable event keydown, which does all of the keydown events but not a specific key...
yourownskill01
 
Posts: 7
Joined: Thu Apr 11, 2013 7:04 pm
Score: 0 Give a positive score

Re: disable keydown events

Postby skydereign » Mon Apr 29, 2013 10:18 pm

Currently you can't with EventDisable. You have to use a variable lock for this.
Code: Select all
if(k_locked==0)
{
    // your keydown k event code goes in here
    // triggers only when k_locked is equal to 0
}

That way you can set the variable k_locked to 1 when you want to disable that key (and back to 0 to unlock it). Note, you do need to create the k_locked variable for this to work.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: disable keydown events

Postby yourownskill01 » Mon Apr 29, 2013 10:53 pm

thanks, got that to work...I have two actors that I am using this code within the script of the collision event ... k_locked=0; basically the weapon I throw at the enemy... when the weapon collides with the enemy unlock the K key....it works when I have this code k_locked=0; only in one of the weapon actors...but when i have it in both weapon actors it doesnt work...it just stays locked.....but if i take away that code from one of the actors it will work for the other actor and let me jump again..
yourownskill01
 
Posts: 7
Joined: Thu Apr 11, 2013 7:04 pm
Score: 0 Give a positive score

Re: disable keydown events

Postby skydereign » Tue Apr 30, 2013 12:00 am

yourownskill01 wrote:but when i have it in both weapon actors it doesnt work...it just stays locked.

This sounds like the event that locks the variable is constantly happening, while the unlock only happens once. If that is the case, then that would explain why it stays locked, and the fix would be to see why that event is repeating and fix that.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: disable keydown events

Postby yourownskill01 » Tue Apr 30, 2013 2:44 am

//within the keydown K


switch(state)
{
case 0:
case 2:

ChangeAnimation("Event Actor", "jump_right", FORWARD);



state=6;
break;

case 1:

case 3:
ChangeAnimation("Event Actor", "jump_left", FORWARD);



state=7;
break;

case 8:

case 9:
;
}

if(k_locked==0)
{
switch(jump)
{
case 0:

if(AcornCount.textNumber>=13)
{
CollisionPlayer.y-=7;

}



if(AcornCount.textNumber<13)
{
CollisionPlayer.y-=10;

}
jump=1;
PlaySound2("data/PlayerJump.wav", 1.000000, 1, 0.000000);
break;

}
}
yourownskill01
 
Posts: 7
Joined: Thu Apr 11, 2013 7:04 pm
Score: 0 Give a positive score

Re: disable keydown events

Postby yourownskill01 » Tue Apr 30, 2013 8:52 pm

figured it out...because I had removed the collision state of the enemy once the player bullet hits him..it messes up the code.. anyway thanks
yourownskill01
 
Posts: 7
Joined: Thu Apr 11, 2013 7:04 pm
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron