PDA

View Full Version : Movie Clip x,y movement/c


cdrake
06-19-2005, 03:17 AM
Ive got this code that moves a movie clip on the stage.

onClipEvent (enterFrame) {

if (Key.isDown(Key.UP)) {

_y -= _root.carspeed;

}

if (Key.isDown(Key.DOWN)) {

_y += _root.carspeed;

}

if (Key.isDown(Key.LEFT)) {

_x -= _root.carspeed;

}

if (Key.isDown(Key.RIGHT)) {

_x += _root.carspeed;

}

}

The code works like it should but I want to prohibit the user from hitting the LEFT and UP keys together etc. I want it to go up down left right not sideways.

Thanks

cdrake
06-19-2005, 06:25 PM
Also I have a hittest that is suppose to stop the car from going any farther when it hits the wall. If you hit the while and are still holding the UP arrow key it works like I want it to. The car touches the wall but goes no farther. The problem is when you let the key up. It pushes the car back a few pixels and I was wondering how I could stop it.

onClipEvent (enterFrame) {
if (hitTest(_root.car.ballhit) == true) {
trace("hooray")
_root.car._x -= _root.carspeed;
stop();
}
}

cdrake
06-21-2005, 04:42 AM
ok, I figured both of them out.

for the movement I had to chance the if statements to else if so it will only check one at a time.

For the hittest I just put another movie clip at the front of the car and just called a hittest on it instead of the car.