开发者

Is it possible to divide up boundingBox?

开发者 https://www.devze.com 2023-02-12 02:58 出处:网络
In cocos2d, i\'ve got two objects that I want to detect collision with. Im using CGrectintersectsrect, which has been working fine thus far.

In cocos2d, i've got two objects that I want to detect collision with. Im using CGrectintersectsrect, which has been working fine thus far. But I want to divide up the bounding box of one of my objects into 4 quarters, so th开发者_如何学Goat if my object collides in any one of these quarters, appropriate physics can then be applied.

At the moment, there is only 1 large boundingBox which is insufficient. Ideally I would want 4+...

Is this possible, and if so how could i achieve this? If not, is there any other avenue that could work? Thanks everyone, once again :)


The boundingbox method returns a CGRect. You have to divide your rect manualy, there is no pre-made method for that. Otherwise if there is a lot of objects, the best way to detect the collisions is to use Box2d. You can follow this tuto to see How To Use Box2D For Just Collision Detection with Cocos2D iPhone tutorial.

0

精彩评论

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

关注公众号