|
-
BitmapData.hitTest() how accurate?
I am using BitmapData.hitTest() and want to know why it is not accurate.
and the next question will be, how to make it accurate.
Code:
public static function pixelHitTest(mc1:MovieClip,mc2:MovieClip):Boolean {
var mc1bd:BitmapData = new BitmapData(mc1.width, mc1.height, true, 0);
mc1bd.draw(mc1);
var mc2bd:BitmapData = new BitmapData(mc2.width, mc2.height, true, 0);
mc2bd.draw(mc2);
if (mc1bd.hitTest(new Point(mc1.x, mc1.y), 0xFF, mc2bd, new Point(mc2.x, mc2.y))) {
return true;
} else {
return false;
}
}
here is the link to show that it is not accurate.
http://www.geocities.com/arian_m3/bitmaphittest.swf
thank you in advance
Last edited by ArielGenesis; 09-06-2007 at 01:46 AM.
-
can someone help me with this? I have no idea where to go?
-
I am almost positive that it is accurate, you are just using it improperly. I have never used bitmap hittests, but I know there are lots of tutorials on them which are extremely accurate.
The greatest pleasure in life is doing what people say you cannot do.
- Walter Bagehot
The height of cleverness is to be able to conceal it.
- Francois de La Rochefoucauld
-
I know, I took the function from somewhere else? is there is some special cases? like i have to do something or I should not do something. I also copy paste and tweak the code from FFiles. Thank you. But I am still confused.
-
Senior Member
Well...first of all, I don't see a reason to convert these to bitmapdata...secondly, look at where the point you're testing is... it's at x:0 y:0 on mc1. So if mc1 has no actual pixels at its origin point, the test will return false...
-
well, It was a test, so I convert it. May be ur right, let me check that again.
-
yoho
hahhahha
Its working
thanksss
-
I was having some weird false positives in a program I was doing awhile back-
I had a big "+" shaped object and a smaller character- knowing about bounding boxes I broke the "+" into squares the size of the character but the hit tests would sometimes return positive where they obviously were not.
I eventually ended up using this complicated class someone else gave me for pixel precise hit tests to get around it.
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
|