I have been experimenting with complex multi-shape physics bodies. It’s easy enough to set up in Corona, but in my testing, I’m getting multiple hits returned by the collision detection engine when an object collides with both bodies in a single game cycle (and this can happen more often than you might think!)
Take the example image below as a reference. The red ball falls directly down and collides with the 2-shape body (blue). It hits basically in the center of this blue body, and technically strikes both objects at the same time. This registers TWO hits with the collision engine, even though the blue body is defined as one physical object (just with two body parts).
So I’m wondering if there’s any way to prevent this. Technically, Corona and Box2D aren’t “wrong”… the red ball really IS hitting both blue shapes. But I would like to register the entire blue body as one shape in regards to the collision system. Why? In my game, the red ball striking the blue shape costs the player 1 life point… so in this case, it knocks off 2 life points, which really isn’t correct. Just to clarify again, this blue body is defined as a multi-body physical object, not two separate bodies.
Using the “phase” commands like “phase="began"
” does not fix the issue.
I considered setting a flag such as “justCollided=true” and then setting it to “false” in the next game cycle using a Runtime listener, but this seems like a tedious addition to (what should be) a more simple solution. Any other ideas? I could probably re-arrange the 2 bodies in a horizontal orientation, but this won’t solve my problem either… the ball won’t always be falling from above, it might strike the blue shape from any direction, which could lead to these multiple hit registers. Argh! A little frusterating.
Brent Sorrentino
Ignis Design
[import]uid: 9747 topic_id: 9502 reply_id: 309502[/import]