Box2D Forums

It is currently Sun May 19, 2013 3:31 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Jul 28, 2011 2:22 pm 
Offline

Joined: Tue Feb 22, 2011 8:23 pm
Posts: 9
Hi,

I'm trying to make a game where you can shoot objects out of a cannon, and I need to prevent the cannon from colliding with the objects, but both the cannon and the objects should collide with the terrain. Because this is just a simple exception of collision between 2 types of objects, I'd like to run a quick check on the userdata of the fixtures and if one of each of the fixtures is from the cannon or the objects it shoots, i'd like to disable the contact.

This is my code:

box2dWorld.addEventListener(ContactEvent.BEGIN_CONTACT, filterContacts)

private function filterContacts(e:ContactEvent):void
{
FlashConnect.trace(e)
}

However, I even though my game runs fine, nothing is ever traced... Am I doing something wrong?

Thanks,

-Hamed


Top
 Profile  
 
PostPosted: Sat Jul 30, 2011 10:34 pm 
Offline

Joined: Mon May 23, 2011 9:41 am
Posts: 18
If you want to prevent the collision between 2 objects just use maskBits and categoryBits. Check this forum if you want to understand how they work : http://www.cocos2d-iphone.org/forum/topic/14546


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

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


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