i made this code up for a game i am making:
onClipEvent (load) {
moveSpeed = 10;
mdirection = 0;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
this._x += moveSpeed;
mdirection = 1;
} else if (Key.isDown(Key.UP)) {
this._y -= moveSpeed;
mdirection = 4;
} else if (Key.isDown(Key.DOWN)) {
this._y += moveSpeed;
mdirection = 2;
} else if (Key.isDown(Key.LEFT)) {
this._x -= moveSpeed;
mdirection = 3;
} else {
mdirection = 0;
}
if (this.hitTest(_root.block_mc)) {
if (mdirection == 1) {
_x -= moveSpeed;
}
if (mdirection == 2) {
_y -= moveSpeed;
}
if (mdirection == 3) {
_x += moveSpeed;
}
if (mdirection == 4) {
_y += moveSpeed;
}
}
}
does anyone know how to simplify it of a different method of doing it because i thought i saw a different way somewhere else ?