Libgdx:绕z轴变换vector2

Libgdx: transform vector2 around z-axis

我正在尝试将塔防游戏从 xna (c#) 移植到 libgdx (java)。

但现在我遇到了一个问题,有一个函数可以将子弹从塔中绕 z 轴旋转到敌人的方向。

public void SetRotation(float value){
    rotation = value;
    velocity = Vector2.Transform(new Vector2(0, -speed), Matrix.CreateRotationZ(rotation));
}

这是使用 xna 的 c# 代码。有人知道如何在 libgdx 中执行此操作吗?

这是教程中的 link 形式:http://xnatd.blogspot.de/2010/10/tutorial-7-firepower.html

希望有人能帮帮我..

Vector2#rotate rotate the vector around the Z axis. Note that it needs the angle in degrees. If the angle you have is in radians then use the rotateRad 方法。

velocity.set(0, -speed).rotate(value);
//or
velocity.set(0, -speed).rotateRad(value);