是否可以划分boundingBox?
在 cocos2d 中,我有两个想要检测碰撞的对象。 我使用 CGrectintersectsrect,到目前为止一直运行良好。 但我想将一个物体的边界框分成 4 个部分,这样如果我的物体在其中任何一个部分发生碰撞,就可以应用适当的物理原理。
目前,只有 1 个大的boundingBox,这是不够的。理想情况下,我想要 4+...
这可能吗?如果可以,我怎样才能实现这一目标? 如果不行,还有其他可行的途径吗? 谢谢大家,再次感谢:)
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 that 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 :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
boundingbox 方法返回一个 CGRect。您必须手动划分矩形,没有预先制定的方法。
否则,如果有很多对象,检测碰撞的最佳方法是使用 Box2d。你可以按照这个教程来看看
如何使用 Box2D只是使用 Cocos2D iPhone 进行碰撞检测教程。
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.