paradox555
01-01-2009, 09:41 PM
Hello, I am making a game and finished coding for the character but have run into a bit of a roadblock. I'm using hittest to keep it from passing bounderies, but it isn't working. Here is my code, and could you tell me what is wrong?
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
if (!_root.player.hitTest(_root.wall,wall2)) {
_root.player._x -= 10;
}
}
if (Key.isDown(Key.RIGHT)) {
if (!_root.player.hitTest(_root.wall,wall2)) {
_root.player._x += 10;
}
}
if(Key.isDown(Key.DOWN)) {
if (!_root.player.hitTest(_root.wall,wall2)) {
_root.player._y += 10;
}
}
if(Key.isDown(Key.UP)) {
if (!_root.player.hitTest(_root.wall,wall2)) {
_root.player._y -= 10;
}
}
}
Whats wrong with the code?
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
if (!_root.player.hitTest(_root.wall,wall2)) {
_root.player._x -= 10;
}
}
if (Key.isDown(Key.RIGHT)) {
if (!_root.player.hitTest(_root.wall,wall2)) {
_root.player._x += 10;
}
}
if(Key.isDown(Key.DOWN)) {
if (!_root.player.hitTest(_root.wall,wall2)) {
_root.player._y += 10;
}
}
if(Key.isDown(Key.UP)) {
if (!_root.player.hitTest(_root.wall,wall2)) {
_root.player._y -= 10;
}
}
}
Whats wrong with the code?