2

iPhone 游戏开发和 Box2D 的新手。

我正在开发一个游戏,我可以在其中移动(拖动)可能与其他物体碰撞的静止物体。

如何使这些物体在具有重力的 Box2D 世界中静止,同时保持它们与动态物体碰撞的能力?

一个随机的想法是一直对这些物体施加与重力相等的力。有更好或更简单的方法吗?静态物体会有帮助吗?

4

1 回答 1

3

Static bodies will collide with dynamic objects but not other static objects. That sounds like what you want, but it's not clear from your description what the "other bodies" in question are.

You cannot disable gravity on a per-object basis; exerting a force equal to the opposite of gravity will usually work but can, due to rounding errors, accumulate small velocities. A better approach is to set gravity to 0 and manually apply a gravitational force on the objects you do want affected by gravity.

于 2010-09-20T12:20:13.013 回答