Problems with hitTest
go to http://www.knut.espenish.com/speedr...tent/game.html.
My hitTest function only works on the y-axis, and i have no idea why.
Can someone please help me…
this is the code…
onClipEvent (enterFrame) {
// _root.speed = speed;
if (Key.isDown(Key.UP)) {
speed += 3;
}
if (Key.isDown(Key.DOWN)) {
speed -=3;
}
if (Key.isDown(Key.LEFT)) {
xSpeed = xSpeed -3;
}
if (Key.isDown(Key.RIGHT)) {
xSpeed = xSpeed +3;
}
this._x = this._x + xSpeed;
xSpeed = xSpeed * 0.75;
// Hit test Function
x = xSpeed;
y = speed*-1;
if (_root._root.road.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
}
}
Cheers
Knutlig