|
-
Simple Hittest problem
I've been trying to write a hittest that will work for rounded walls on my RPG D: But i've been epic phailing. Heres my code:
onClipEvent(load){speed=10;}onClipEvent(enterFrame ){if(Key.isDown(Key.UP)){this._y-=speed;this.gotoAndStop(5);}if(Key.isDown(Key.DOWN )){this._y+=speed;this.gotoAndStop(6);}if(Key.isDo wn(Key.RIGHT)){this._x+=speed;this.gotoAndStop(7); }if(Key.isDown(Key.LEFT)){this._x-=speed;this.gotoAndStop(8);}
If someone could help me out I would love them forever <3
-
okay... i've dealt with rounded hit test stuff like this before. What you want to do is check the distance between you and the center of the rounded wall.
Essentially you check for the hypotenuse.
Code:
!!!not actual coding!!!
if (( (y*y) + (x*x) ) < radius_of_wall*radius_of_wall)
{
hittest = true;
}
42 is not the answer to life, the universe, and everything... Dr Pepper is.
-
I don't see any hit test code in what you have above so I am not too sure what is going on there. you can use this for a hit test
use:
mc.hitTest(x, y, shapeFlag) shapeFlag set to true, will fire if you hit actual "pixels" not the bounding box.
or use:
mc.hitTest(target) target is the movieclip you want to check against, it will check actual pixels not bounding box.
not sure that is what you are looking for though
IMS
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|