简体   繁体   English

如何使用libgdx检测具有随机形状的两个精灵之间的碰撞

[英]How to detect collision between two sprites with random shapes with libgdx

I'm new to libgdx and to game development in general.我是 libgdx 和游戏开发的新手。 I'm trying to make a 2D game with libgdx on Android.我正在尝试在 Android 上使用 libgdx 制作 2D 游戏。 For now, for detecting collisions I was using rectangles and the "overlaps" method, it worked very well.现在,为了检测碰撞,我使用了矩形和“重叠”方法,效果很好。 I now want to add very specific objects into my game that are randomly generated and with various shapes like circles, stars etc.. Can you guys help me find a way to detect these kind of collisions ?我现在想在我的游戏中添加非常具体的物体,这些物体是随机生成的,具有各种形状,如圆形、星星等。你们能帮我找到一种方法来检测这些碰撞吗? I heard about Box2D, should I use that ?我听说过 Box2D,我应该使用它吗? Thank you very much for your help !非常感谢您的帮助 !

I believe you can use the overlaps method with any polygon.我相信您可以对任何多边形使用重叠方法。 You pass it in as an array of the vertices of the object.您将它作为对象顶点的数组传入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM