cocos2d中的碰撞检测
我想在同一行中检测两次碰撞检测。
例如:-(见下图)
椭圆和矩形或检测到的。之后我的椭圆将沿着直线路径向下移动并检测另一个矩形。
第一个(在轨迹路径中行驶)工作正常。第二个我想沿直线向下传递以进行碰撞检测。
如何进行这个过程。
i want to detect collision detection two times in same row.
for example:-(see the below image)
the ellipse and rectangle or detcted. after that my ellipse will travelling in the straight line path to down and detect the another rectangle.
first one is( travelled in trajectory path ) working fine. second one i want to pass in straight line to down for collision detection.
how to do this process.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 Box2D 物理库进行碰撞检测。它是迄今为止适合您的情况的最佳选择,并且在 Cocos2d 中得到了很好的支持。
请参阅此处: http: //www.raywenderlich.com/606/how-to-use-box2d-for-just-collision-detection-with-cocos2d-iphone
Use the Box2D physics library for collision detection. It is by far the best option in your case and elegantly supported in Cocos2d.
See here: http://www.raywenderlich.com/606/how-to-use-box2d-for-just-collision-detection-with-cocos2d-iphone
据我所知,cocos2d 没有精灵碰撞检测,因为它不是物理引擎。如果您希望自动检测碰撞,请使用 Cocos2d 支持的 Box2D 或花栗鼠物理引擎。
如果您要检查碰撞的对象数量很少,您可以直接跑过您的对象并检查其中一些(或者如果对您来说足够的话,只检查一个)是否与其他对象重叠。
制作更复杂的碰撞检测将使您编写物理引擎的碰撞检测部分。使用现有的要简单得多
As i know cocos2d have no collision detection of sprites because it's not a phys engine. If you want the collision be detected automatically use Box2D or chipmunk physics engine, supported by cocos2d.
If the number of object you want to check for collision is small you can just run over your object and check if some of them (or only one if it's enough for you) overlaps with the others.
Making more complex collision detection will bring you for writing a collision detection part of a physics engine. It's much simpler to use en existing one