Page 1 of 1
disable keydown events
Posted:
Mon Apr 29, 2013 9:50 pm
by yourownskill01
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...
Re: disable keydown events
Posted:
Mon Apr 29, 2013 10:18 pm
by skydereign
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.
Re: disable keydown events
Posted:
Mon Apr 29, 2013 10:53 pm
by yourownskill01
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..
Re: disable keydown events
Posted:
Tue Apr 30, 2013 12:00 am
by skydereign
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.
Re: disable keydown events
Posted:
Tue Apr 30, 2013 2:44 am
by yourownskill01
//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;
}
}
Re: disable keydown events
Posted:
Tue Apr 30, 2013 8:52 pm
by yourownskill01
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