如何围绕中心旋转矩形?我在 ShapeRenderer 中找到了旋转功能:
void rotate(float axisX, float axisY, float axisZ, float angle);
但它围绕 0,0 坐标旋转,我想围绕它的中心旋转形状。
最佳答案
如果您查看 documentation对于 ShapeRenderer,第二个示例向您展示了如何将框的中心设置在位置 {20, 12, 2} 并使用平移围绕 z 轴旋转。你需要做同样的事情,例如
this.m_ShapeRenderer.begin(ShapeType.Rectangle);
this.m_ShapeRenderer.setColor(1.f, 1.f, 1.f, 1.f);
this.m_ShapeRenderer.identity();
this.m_ShapeRenderer.translate(20.f, 10.f, 0.f);
this.m_ShapeRenderer.rotate(0.f, 0.f, 1.f, 45.f);
this.m_ShapeRenderer.rect(x, y, 40.f, 20.f);
this.m_ShapeRenderer.end();
希望这对您有所帮助。
关于java - libgdx shaperenderer 如何围绕其中心旋转矩形?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14091734/