Forge2DGame:没有效果设置- body.position.setFrom(info.delta.game).&



在这个例子中,你可以通过设置body.applyLinearImpulse.

来拖动一个BodyComponent(不是在可拖动点,而是在某个因素上)。如果我尝试周围拖动,设置body.position我没有效果。我希望能够在特定的拖动点上拖动BodyComponent。

示例代码第37行:
@override
bool onDragUpdate(DragUpdateInfo info) {
// final worldDelta = Vector2(1, -1)..multiply(info.delta.game);
// body.applyLinearImpulse(worldDelta * 1000);
body.position.setFrom(info.delta.game);
return false;
}

你不应该直接操作body.position,因为这可能会破坏物理引擎的稳定性。

对于您的用例,您可能希望使用MouseJoint代替:

https://github.com/flame-engine/flame/blob/ba617790e4a7ca4dc03f4a2e29de43d42efd3482/packages/flame_forge2d/example/lib/mouse_joint_sample.dart

最新更新