Well anyways I want my character to move to: the left, right, up and down. Simple the code for is:
onClipEvent (enterFrame) { if (Key.isDown(Key.LEFT)) { _x--; } if (Key.isDown(Key.RIGHT)) { _x++; } if (Key.isDown(Key.UP)) { _y--; } if (Key.isDown(Key.DOWN)) { _y++; } } This would be the code. However I want my character to change when moving, its basically a sprite, I want it to turn left, as if its looking to the left, when i hold the left key, it walks to the left and if I stop holding the key the character stops moving. This is the code iv got so far: [code]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); } else { if (Key.isDown(Key.DOWN)) { _y++; } gotoAndStop(1); } }
This kinda works, if i hold the down key, the sprite moves down with the correct animation and when i let go, it stops moving, however if I click the other keys it goes in the right directions but the sprite doesn't change direction it always looking down.
So help! Iv tried Adobe flash center but no help:S
I'm using AS2 coding.