collision multiple shapes?

Hi,
Just bought corona…love it!! Saves so much time it’s unbelievable. I could never go back to obj c.
One thing I need though is to be able to detect what part of a sprite got collided with. Since it’s made of
multiple shapes is there a way to get that info from the collision callback. I could have used multiple sprites in a group
but they would use the local coordinates of the parent so that wouldn’t work I’m guessing.
Mike [import]uid: 8561 topic_id: 2052 reply_id: 302052[/import]

Hi, Mike. Thanks for the compliment, and your question is a good one!

You are correct that Box2D does know which element (or “fixture” in Box2D language) of a multi-element body was collided with. But our current API “anonymizes” body elements, so that information is lost to the end user.

One design goal is avoiding the user having to submit a “table of named sub-tables” every time a body is created, which would be a messy API. Also, collisions are an area where we tread carefully, since we’re talking about events that may happen hundreds of times per frame, and small overheads multiply rapidly.

However, assuming the ORDER of submitted body elements is preserved, it might be possible to add a field to collision events that simply gives the index number of the body element involved in the collision – I’ll look into this, since it seems like there should be a lightweight solution. Logged as internal issue #1190.

(You are also correct that display groups are not the way to solve this, since they introduce another coordinate system. As a workaround, you might try joining two separate bodies with a “weld” joint.) [import]uid: 3007 topic_id: 2052 reply_id: 6419[/import]

Thanks!
Ok…I didn’t think about the weld joint (I remember reading on the box2d forum that weld joints are inefficient) but for a few bodies I think it’s ok.
Yeah I’m all for a clean API as a developer that likes things as simple as possible. Although when I’m creating a body with multiple shapes I’m adding
them with each shape in a table…I would imagine just adding some id to that table would be all that’s needed? [import]uid: 8561 topic_id: 2052 reply_id: 6422[/import]