Skip to main content
Participant
February 19, 2008
Question

movements

  • February 19, 2008
  • 1 reply
  • 208 views
Basically im making an animation that allows the user to move a character, however when one of the four keys are pressed, the character movement changes, however so do does the animation (for example if I click the left key the character turns to the left and if i hold the left key the character moves to the left, as if the it looks like it is moving. i have the animation for this).

Basically I can't seem to stop the character from walking, they just keep walk until another key is pressed. So can anyone help me make it go back into a stance? This is my code im using:

onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
_x--;
gotoAndStop(5);
}
if (Key.isDown(Key.RIGHT)) {
_x++;
gotoAndStop(6);
}
if (Key.isDown(Key.UP)) {
_y--;
gotoAndStop(4);
}
if (Key.isDown(Key.DOWN)) {
_y++;
gotoAndStop(3);
}
}
This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
February 20, 2008
when each of those keydowns are detected, start a listener to check if (and when) that key is up. if it is, goto the stance frame.