6 Replies Latest reply on Jul 12, 2009 9:00 AM by kglad

# [as1, as2] Complex Collision Detection

Could any one tell me the way I do a good collision detection function?
I don´t want the hitTest method, because it only checks whether two movieclips´s rectangles are colliding.
I want something broader, like two moviclips colliding with irregular shapes on it. And not colliding its rectangles but its shapes.
Ah, I can´t use gskiner´s class .
Thank you .
• ###### 1. Re: [as1, as2] Complex Collision Detection

why can't you use gskinner's class?

• ###### 2. Re: [as1, as2] Complex Collision Detection

The simple quick answer is usually use gSkinner's class. I have no idea why you wouldn't want to use it...

But if that isn't the case then you need to do some serious heavy lifting and write your own code to do it. There are all kinds of complex ways to do this and it is a very difficult problem and requires a great deal of cleverness.

There is a lot of good work here to read.

http://lab.polygonal.de/index.php?s=collision

I saw one of your earlier posts and you also didn't want to use the simpler trick of a ring of "feeler" movieclips inside your movie clips because it was too slow. However you could easily speed that up a lot.

First check if the bounding boxes of any of your "big" items are hitting.

If they aren't you are done.

If they are, save which pairs are hitting and then...

Only check the hits of the feelers for those items.

If you are clever about that it will work pretty well.

Also remember that if you have 2 items you only have to check 1 time. Is item 0 touching item 1. You don't have to check if item 1 is touching item 0.

With three items you only have to check 0-1, 0-2, and 1-2. So be clever about your loops.

• ###### 3. Re: [as1, as2] Complex Collision Detection

Because I´m not allowed to do it.

I´m doing a licensed game that can´t use others code.

Date: Fri, 10 Jul 2009 16:50:19 -0600

Subject: Complex Collision Detection

why can't you use gskinner's class?

>

• ###### 4. Re: [as1, as2] Complex Collision Detection

to code your own pixel-level hit detection use the bitmapdata class.  it has a hittest method

• ###### 5. Re: [as1, as2] Complex Collision Detection

Thank you ;).

Date: Sun, 12 Jul 2009 09:40:58 -0600