小智 9
一旦你知道,这很容易Transform.
我们以圆形夹具为例,因为它们最容易展示.
// we need to get the body's position, let's use a Vector2 to store it.
Vector2 vec = new Vector2();
Body body = fixture.getBody();
// what is this magic? Why, it's a wonderful object that transforms fixture
// position information based on the body's position!
Transform transform = body.getTransform();
CircleShape shape = (CircleShape) fixture.getShape();
vec.set(shape.getPosition());
// apply the transformation
transform.mul(vec);
// now vec.x and vec.y will be what you want!
Run Code Online (Sandbox Code Playgroud)
简单!
但是如果你有一个多边形而不是圆形怎么办?再简单!只需将变换应用于形状中的每个顶点即可.