Forum Topic: How to detect TWO keys pressed?

(418 views • 34 replies)

This topic is 2 pages long. [ 1 | 2 ]

<< < > >>
None

Powergames

Reply To Post Reply & Quote

Posted at: 2/6/09 02:28 PM

Powergames NEUTRAL LEVEL 19

Sign-Up: 05/14/06

Posts: 72

if (Key.isDown(68) and Key.isDown(65)) {
this._x +=0;
}else if (Key.isDown(68)){
this._x+=(walkspeed);
}else if (Key.isDown(65)){
this._x-=(walkspeed);
}
is the sort of code you want


None

FatKidWitAJetPak

Reply To Post Reply & Quote

Posted at: 2/6/09 05:10 PM

FatKidWitAJetPak LIGHT LEVEL 24

Sign-Up: 07/28/07

Posts: 3,778

At 2/6/09 02:08 PM, TheSongSalad wrote: you could just say

if(key.IsDown(00) {
if(key.IsDown(00){

}
}

just put two conditions in, and just put what you want to happen after the second one. just be sure to end both of them

Like what people said earlier, there is no need to put two if conditions.

The Fallout 3 Fan Club. Join Today!
Voice Acting TUTORIAL!
Click My Sig Below If You Need A Voice Actor! Oh And I Love Pancakes. ROOOOOOOOOAAAAAAAAARRRRRRRRRRR!!!

BBS Signature

None

FatKidWitAJetPak

Reply To Post Reply & Quote

Posted at: 2/6/09 05:12 PM

FatKidWitAJetPak LIGHT LEVEL 24

Sign-Up: 07/28/07

Posts: 3,778

At 2/6/09 02:28 PM, Powergames wrote: if (Key.isDown(68) and Key.isDown(65)) {
this._x +=0;
}else if (Key.isDown(68)){
this._x+=(walkspeed);
}else if (Key.isDown(65)){
this._x-=(walkspeed);
}
is the sort of code you want

I actually tried that out at first... it didnt end up working due to the fact I have other coding that tells everything to move. I will just need to mess around with my engine becaus eI think thats what is changing my other movement code. Although, I am able to use it to make my charecter stop when he is frozen. *attacked by a snowman*

The Fallout 3 Fan Club. Join Today!
Voice Acting TUTORIAL!
Click My Sig Below If You Need A Voice Actor! Oh And I Love Pancakes. ROOOOOOOOOAAAAAAAAARRRRRRRRRRR!!!

BBS Signature

None

FatKidWitAJetPak

Reply To Post Reply & Quote

Posted at: 2/6/09 06:28 PM

FatKidWitAJetPak LIGHT LEVEL 24

Sign-Up: 07/28/07

Posts: 3,778

Hmm... after tons of tests, I realized that for some VERY strange reason... the coding is canceled when BOTH keys are pressed when using this coding.

onClipEvent(enterFrame) {
if (Key.isDown(65)) {
this._x += 3;
}
if (Key.isDown(68)) {
this._x -= 3;
}
}

What the hell? well whatever this DOES work. I am going to apply some coding that fixes a quick glitch then all the glitches will be finished! YAAAYYY

The Fallout 3 Fan Club. Join Today!
Voice Acting TUTORIAL!
Click My Sig Below If You Need A Voice Actor! Oh And I Love Pancakes. ROOOOOOOOOAAAAAAAAARRRRRRRRRRR!!!

BBS Signature

None

FatKidWitAJetPak

Reply To Post Reply & Quote

Posted at: 2/6/09 06:30 PM

FatKidWitAJetPak LIGHT LEVEL 24

Sign-Up: 07/28/07

Posts: 3,778

Oh I know why!!! Its because when pressing A it goes to the left by 3... and to the right by 3 when pressing D. If you press them both, the movie clip doesnt know where to go and just sets there.

BRILLIANT...

But this doesn't actually make something only happen when two keys are pressed.. it just stops something from moving when two keys are pressed.

The Fallout 3 Fan Club. Join Today!
Voice Acting TUTORIAL!
Click My Sig Below If You Need A Voice Actor! Oh And I Love Pancakes. ROOOOOOOOOAAAAAAAAARRRRRRRRRRR!!!

BBS Signature

All times are Eastern Standard Time (GMT -5) | Current Time: 10:25 AM

<< Back

This topic is 2 pages long. [ 1 | 2 ]

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!