如何使用 libgdx 在 Box2D 的碰撞事件中设置 false/NoCollision?
我正在为 Android 开发一款 2D 水下动作角色扮演游戏,使用 Box2D 作为物理引擎,主要用于碰撞检测、碰撞响应以及游戏角色在由墙壁、岩石和其他生物组成的环境中的移动。
我正在尝试实现角色动画(按照 什么是最好的在 Box2D 中制作角色动画的方法)。
问题是我想在碰撞发生时抑制碰撞响应。有人告诉我应该在碰撞事件中设置“NoCollision”,我假设您在预求解事件中通过 b2Contact::SetEnabled(false) 来设置。但是,libgdx JNI 实现并没有实现接口中的 pre-solve 或 post-solve 方法,因为它可以“以另一种方式完成” 如此处所述。
有谁知道我还能怎么做?
我是 Box2D 的新手,发现它非常困难,所以任何帮助将不胜感激!
I am developing a 2D, underwater, action-RPG for Android, using Box2D as the physics engine, mainly for collision detection, collision response and movement of in-game characters within an environment comprised of walls, rocks, and other creatures.
I am trying to implement character animations (as per What's best way to do character animations in Box2D).
The problem is that I want to suppress the collision response when a collision happens. I have been told that I should set 'NoCollision' in the collision event, which I assume you do by b2Contact::SetEnabled(false) in the Pre-Solve Event. But, the libgdx JNI implementation doesn't implement the pre-solve or post-solve methods in the interface, as it can "be done another way" as stated here.
Does anyone have any idea how else I might do this?
I'm new to Box2D, and finding it very hard going, so any help would be much appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没关系,我已经更新了 JNI 接口来实现 pre 和 post 解决方法,所以现在我可以使用: contact.SetEnabled(false);
Never mind, I've updated the JNI interface to implement the pre and post solve methods, so now I can just use: contact.SetEnabled(false);