views:

290

answers:

2

I'm using Box2D on my iPhone app using Cocos2D. I'm using mouse joint to drag objects by touch. The touch event is handled to find the corresponding Box2D body using AABB queries.

I would want to extend the area of Box2D bodies. In this way, I can touch approximately my body and still respond.

Does it exist any way to do this? Thanks!

+2  A: 

The b2AABB object you use in the AABB query is a rectangle; just make it bigger.

You can also place a sensor circle with a suitable radius under the mouse pointer. This is more accurate than an AABB query, since it triggers on actual shape collisions rather than just telling you which bounding boxes overlap.

Marcelo Cantos
+1  A: 

What if you made an invisible object that is the larger that your Box2D object and use that to sense the touch. Make this the parent of your Box2D object. Then potentially you can pass the unhandled events down to your Box2D body.

milesmeow