开发者

box2d: bigger clickable/touchable area

I'm using Box2D on my i开发者_如何转开发Phone 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!


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜