-
hitTest blues
Well I've tried just about everything from the using distance to determine where the mc is tried every form of the hitTest class possible(for me) and other such technics but nothing seems to be working(usually is easy to get but this is giving me trouble) the mc I wan't to check for collision against is called 'wall' and the mc that the following code is in is called 'player'. I was wondering if anyone could help me find a solution to the problem.
Code:
onClipEvent(load){
speed=5;
function distance(x1,x2,y1,y2){
d = Math.sqrt(((x1-x2)(x1-x2))((y1-y2)(y1-y2)));
return d;
}
}
onClipEvent(enterFrame){
if(Key.isDown(Key.LEFT) && Key.isDown(Key.UP)){
this.gotoAndStop("ul");
this._x -= speed;
this._y -= speed;
}
if(Key.isDown(Key.RIGHT) && Key.isDown(Key.UP)){
this.gotoAndStop("ur");
this._x += speed;
this._y -= speed;
}
if(Key.isDown(Key.LEFT) && Key.isDown(Key.DOWN)){
this.gotoAndStop("dl");
this._x -= speed;
this._y += speed;
}
if(Key.isDown(Key.RIGHT) && Key.isDown(Key.DOWN)){
this.gotoAndStop("dr");
this._x += speed;
this._y += speed;
}
if(Key.isDown(Key.UP) && !Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT)){
this.gotoAndStop("up");
this._y -= speed;
}
if(Key.isDown(Key.DOWN) && !Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT)){
this.gotoAndStop("down");
this._y += speed;
}
if(Key.isDown(Key.RIGHT) && !Key.isDown(Key.UP) && !Key.isDown(Key.DOWN)){
this.gotoAndStop("right");
this._x += speed;
}
if(Key.isDown(Key.LEFT) && !Key.isDown(Key.UP) && !Key.isDown(Key.DOWN)){
this.gotoAndStop("left");
this._x -= speed;
}
}
onClipEvent(KeyUp){
this.gotoAndStop(1);
}
-
Well I've got the simplest hitTest working. hitTest(_root.wall) but it only work for up down left right and not for any diagonal movement any diagonal movement causes it to get "stuck" to the wall
please help