Box2D 旋转一个对象,如何?

lac*_*cas 5 java android rotation box2d

如何在 中旋转对象Box2D?试过..

private static final double DEGREES_TO_RADIANS = (double)(Math.PI/180);
float angle = (float) (45*DEGREES_TO_RADIANS);
object.body.setTransform(object.body.getPosition(), angle);
Run Code Online (Sandbox Code Playgroud)

..但不工作。

Mat*_*Bai 1

使用世界中心代替位置,就像这样

private static final double DEGREES_TO_RADIANS = (double)(Math.PI/180);
float angle = (float) (45*DEGREES_TO_RADIANS);
object.body.setTransform(object.body.getWorldCenter(), angle);
Run Code Online (Sandbox Code Playgroud)