围绕中心点旋转物体

Rotate bodies around around a center point

我有一个游戏世界,其中玩家围绕一个点(如行星)旋转。如何围绕中心点旋转物体?我还想以某种方式能够使用 actor 类 插值之类的东西来移动物体,这可能吗?谢谢!

您可以轻松地通过vector2 进行旋转。

Vector2 vectorbody = new Vector2(50f, 50f);
Vector2 vectorcenter = new Vector2(100f,100f); 
Vector2 vectordis= vectorbody.cpy().sub(vectorcenter);//Displacement vector center to body
vectordis.setAngle( vectordis.angle() + rotatespeed );//Rotate speed can be negative that means it will rotates to other side.
vectordis.add(vectorcenter); //vectordis now became rotated vectorbody
vectorbody.set(vectordis);   //vectorbody updated

你也可以使用actor方法。

只需定义新变量,如 is_in_orbit,如果它为真(在轨道上)则旋转,否则使用演员 类 插值方法移动。

顺便说一句,你也有使用物理学的意见,因为牛顿万有引力定律也是物理学,但它会很复杂,如果出现更多的中心点(你说的行星),可能会导致意想不到的结果。