Box2D Forums

It is currently Tue May 21, 2013 3:58 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Thu Feb 02, 2012 7:00 am 
Offline

Joined: Fri Jan 27, 2012 7:54 am
Posts: 8
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!


Top
 Profile  
 
PostPosted: Mon Feb 06, 2012 8:05 pm 
Offline

Joined: Fri Dec 14, 2007 8:07 pm
Posts: 913
set isGuideShape = true on the boxes inside your root BodyShape. They will dispatch their contact events off of the parent BodyShape rather than themselves.


Top
 Profile  
 
PostPosted: Fri Mar 02, 2012 4:51 pm 
Offline

Joined: Wed May 18, 2011 1:23 pm
Posts: 8
In WCK just change your BodyShape base class to shapes.Box. It doesn't seem to make a difference and then it works fine.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group