Box2D Forums

It is currently Sat May 18, 2013 4:59 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Mon Jun 20, 2011 7:17 am 
Offline

Joined: Mon Jun 20, 2011 3:20 am
Posts: 5
I have searched many forums but I can't seem to find any sample code for this.

How can I detect if Sensor A is currently overlapping Sensor B or not in Box2d Alchemy Port / WCK? :cry:


Top
 Profile  
 
PostPosted: Wed Jun 22, 2011 12:03 pm 
Offline

Joined: Fri Dec 14, 2007 8:07 pm
Posts: 913
I can't recall if sensors don't collide at all. I think they don't. You could get creative with category & mask bits to make one of the bodies behave like a sensor, even if it isn't one.


Top
 Profile  
 
PostPosted: Wed Jun 22, 2011 4:54 pm 
Offline

Joined: Mon Jun 20, 2011 3:20 am
Posts: 5
Thanks for the reply mayobutterI think they are colliding because the BEGIN_CONTACT fires when they touch, but I don't want to use that listener because the END_CONTACT also fires even if Sensor B is still touching Sensor A. Is there someting like
Code:
SensorA.hitTestObject(SensorB)
that i could check anytime i want like in ENTER_FRAME or TIMER? Well it kinda worked but it detects the overlapping of both sensors' rectangle bounding box, not their polygon shape. I'm looking forward to your reply mayo, thanks again!


Top
 Profile  
 
PostPosted: Fri Jun 24, 2011 7:45 am 
Offline

Joined: Mon Jun 20, 2011 3:20 am
Posts: 5
help please..i like wck..anyone?


Top
 Profile  
 
PostPosted: Tue Jul 05, 2011 3:15 am 
Offline

Joined: Mon Jun 20, 2011 3:20 am
Posts: 5
I don't want my code to detect collisions, instead, I want to detect if Sensor A is OVER Sensor B in a 'pixel perfect' manner. :) Is there no solution for this? :D


Top
 Profile  
 
PostPosted: Fri Jul 08, 2011 8:03 am 
Offline

Joined: Fri Dec 14, 2007 8:07 pm
Posts: 913
It sounds like you've got complicated polygon sensors set up with the possibility for multiple contact points?

use something like a contact counter. When you get a BEGIN_CONTACT increment it. When you get an END_CONTACT decrement it. So then you know if it's over zero you've got a contact.


Top
 Profile  
 
PostPosted: Sun Jul 10, 2011 6:45 pm 
Offline

Joined: Mon Jun 20, 2011 3:20 am
Posts: 5
mayobutter wrote:
It sounds like you've got complicated polygon sensors set up with the possibility for multiple contact points?

use something like a contact counter. When you get a BEGIN_CONTACT increment it. When you get an END_CONTACT decrement it. So then you know if it's over zero you've got a contact.


Thanks again for reply. Yes I have tried that before, but I had a problem using that method. You see the problem is when sensor A (smaller) hits sensor B (larger) I get BEGIN_CONTACT BUT when sensor A goes inside sensor B, i get END_CONTACT already, which i supposed it should not because they're still in contact with each other. I have a poly (ellipse-shaped, not so complicated) sensor with 20+ vertices with 50% fill color transparency.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 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