4
votes

I have made a Box2D sensor box in cocos2d. I want a fast way of checking if this box is empty. Is there a simple method in box2d to check if the sensor is making any contact with anything else?

1

1 Answers

2
votes

The recommended way is to check in the contact listener BeginContact callback, to see if one of the fixtures is this box. You can keep a list of all the things currently touching, and remove them from the list in the EndContact function. This will give you a list you can check any time to see what the box is touching.