reportBeginContact in a BodyShape subclass

Hi everybody,

I have a custom object with some boxes inside, and I want the whole object to detect BEGIN_CONTACT events.

The code looks like:

Quote:
public class MyObject extends BodyShape {

public override function create():void {
reportBeginContact = true;
addEventListener(ContactEvent.BEGIN_CONTACT, beginContactHandler);
super.create();
}

private function beginContactHandler(e:ContactEvent):void {
trace("CONTACT DETECTED!");
}
}


With it I don't get the begin contact events, but if I extend my class from shapes.Box, it does. Is this correct? I find strange to subclass my shape from a box, since I have some other shapes (actually shapes.Box) inside. How could I get the contact events when extending direct from BodyShape?

Thanks for your help!
set isGuideShape = true on the boxes inside your root BodyShape. They will dispatch their contact events off of the parent BodyShape rather than themselves.
In WCK just change your BodyShape base class to shapes.Box. It doesn't seem to make a difference and then it works fine.

Original thread: https://box2d.org/forum/viewtopic.php?t=8137