all groups > flash (macromedia) > november 2007 >
You're in the

flash (macromedia)

group:

hit tests



hit tests chrisf671
11/2/2007 12:25:40 AM
flash (macromedia): Hi
I have a problem with hit tests, if you make a object that is any shape other
then a square it createds a invisable square around it and uses the as the edge
for hit tests. I have a ship you move around rounded astriods and i need it to
be exactly where you see the edge, and not where the edge of the box is.
this is the code im using.
Thanks.

_root.spaceship_mc.onEnterFrame = function() {
if(this.hitTest(_root.astriods_mc)) {
gotoAndPlay("you lose", 1);
} else {
this.gotoAndStop(1);
}
};
Re: hit tests clbeech
11/2/2007 2:33:54 AM
Yes, this is called the 'BoundingBox' and represents the min and max space
taken by the instance. There is another method in Flash, using a 'shapeFlag'
based hitTest, but it will only compare a single point. What you're looking
for is to compare two shapes, and this is not supported, but there are
solutions, it's a little complex though. Check out Grant Skinners
CollisionDetection class which does just exactly this:

here: http://www.gskinner.com/blog/archives/2005/10/source_code_sha.html
Re: hit tests chrisf671
11/3/2007 3:01:56 AM
AddThis Social Bookmark Button