Be a Supporter!

Ignoring Key.isDown

  • 180 Views
  • 3 Replies
New Topic Respond to this Topic
mkmetalhead
mkmetalhead
  • Member since: Aug. 9, 2008
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Ignoring Key.isDown 2009-08-13 17:09:46 Reply

I have a simple platformer at the moment and I am trying to trigger an event with an invisible rectangle. The hitTest works absolutely fine and it changes the variable I want it to change, but it is also supposed to gotoAndPlay an animation within the movieclip - but it is ignored because the arrow keys are telling the MC to play a different frame.

Is there anyway that I can get the MC to ignore keyboard input for the duration of around 40 frames within the MC? If not, is there another way around this problem?

Thanks in advance.

swishcheese
swishcheese
  • Member since: May. 12, 2007
  • Offline.
Forum Stats
Member
Level 14
Programmer
Response to Ignoring Key.isDown 2009-08-13 17:16:45 Reply

yeah there is a way. just make a variable called death, make its data type boolean, and set it false.

then in your code where you gotoAndPlay the person walking, put code like:

if(death == false){
gotoAndPlay("walk");
}

then, in the code where you hittest something like:

if(mc.hitTest(mc2)){
death = true;
gotoAndPlay("death");
}
}


BBS Signature
mkmetalhead
mkmetalhead
  • Member since: Aug. 9, 2008
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to Ignoring Key.isDown 2009-08-13 17:30:27 Reply

Thankyou, it wasn't for a death animation, but I understood the idea and it's working now =]

swishcheese
swishcheese
  • Member since: May. 12, 2007
  • Offline.
Forum Stats
Member
Level 14
Programmer
Response to Ignoring Key.isDown 2009-08-13 23:23:59 Reply

At 8/13/09 05:30 PM, mkmetalhead wrote: Thankyou, it wasn't for a death animation, but I understood the idea and it's working now =]

alright, cool glad i could help.


BBS Signature