android box2d如何在更改圆位置时使碰撞工作?

发布于 2025-01-24 20:09:30 字数 359 浏览 4 评论 0原文

我是Box2D Lib的新手,也是Glsurfaceview中的新手,所以我需要您的帮助!!! 我正在使用Android glsurfaceview使用Box2D Lib,并且正在尝试为气泡实现简单的触摸和移动效果。我已经成功地将Android屏幕像素转换为Box2D World Points,我可以按预期移动圆圈,但是碰撞行不通,在这种情况下(我正在移动的圆圈)可以触摸其他圆圈而无需任何碰撞。我该怎么做才能使碰撞起作用?

当我用 applyforce appllinearmimpulse 更改圆形位置时,碰撞正常工作,但是当我我时,碰撞不起作用仅通过设置X和Y坐标来更改位置。

I'm new in Box2D lib and also new in GlSurfaceView so I need your help!!!
I'm using the Box2D lib with android GlSurfaceView, and I'm trying to implement simple touch and move effect for my bubbles. I've successfully converted the android screen pixels to box2D world points and I can move the circles as expected but the collision doesn't work,,, In this case (the circle which I'm moving) can touch the other circles without any collision. What can I do to make the collision work?

When I'm changing the circles position with applyForce or applyLinearImpulse then the collision works fine, but the collision doesn't work when I'm changing the position with just setting the x and y coordinates.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

坦然微笑 2025-01-31 20:09:30

我如何移动身体/演员通过拖动鼠标/手指吗?

另一个圆圈可能正在睡觉,无法检测到接触,请尝试使睡眠失败。
circlebody.setsleepingalowed(false);

ie,因为传送不在Box2D碰撞分辨率之外,当圆圈与正常碰撞时,圆圈不会自动唤醒。

How do I move a body/actor by dragging the mouse/finger?

The other circle might be sleeping and unable to detect a contact, try disabling sleeping.
circleBody.setSleepingAllowed(false);

i.e. because teleportation is outside of box2d collision resolution the circle doesn't wake up automatically as it does when its collided with normally.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文