AS2 - player movement problem
Hello.
I need help in improving the code to move the character in my game (AS2).
The problem is that I would like move the player character only in four directions (left, right, up, down)
For movement I'm using a script:
onClipEvent(enterFrame){
if(Key.isDown(Key.RIGHT)){
_root.player._x += 5;
}
if(Key.isDown(Key.LEFT)){
_root.player._x -= 5;
}
if(Key.isDown(Key.UP)){
_root.player._y -= 5;
}
if(Key.isDown(Key.DOWN)){
_root.player._y += 5;
}
}
If I press two buttons (up and left or up and right or down and left or down and right) at the same time it moves diagonally.
I would like to block the possibility of pressing two buttons. Let nothing happen when two buttons are pressed.
Thx for help