tomo
tomo

Reputation: 93

Box2d contact sensor COCOS2D

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?

Upvotes: 4

Views: 318

Answers (1)

iforce2d
iforce2d

Reputation: 8262

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.

Upvotes: 2

Related Questions