長方形の中心をどのように回転させるのですか?libgdx shaperenderer四角形を中心に回転させるにはどうすればいいですか?
void rotate(float axisX, float axisY, float axisZ, float angle);
しかし、それは0,0座標を中心に回転し、その中心を中心に回転したいと思います。
長方形の中心をどのように回転させるのですか?libgdx shaperenderer四角形を中心に回転させるにはどうすればいいですか?
void rotate(float axisX, float axisY, float axisZ, float angle);
しかし、それは0,0座標を中心に回転し、その中心を中心に回転したいと思います。
ShapeRendererのdocumentationを見ると、2番目の例では{20、12、2}の位置にボックスの中心を設定し、translateを使用して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();
これが役に立ちます。
使用この方法(official docs):
public void rect(float x, float y,
float originX, float originY,
float width, float height,
float scaleX, float scaleY,
float degrees)
はShapeRenderer.ShapeType.Line又はShapeRenderer.ShapeType.Filledを用いてX/Y平面内で矩形を描きます。 xとyは左下隅を指定します。 originXとoriginYは、矩形を回転させる点を指定します。
は、このようにそれを使用する:
renderer.rect(x-width/2, y-height/2,
width/2, height/2,
width, height,
1.0f, 1.0f,
myRotation);
おかげ厥が役立ち(xおよびyは矩形の中心点です)。 – JustOneMan
それは私のために働いていない。私が翻訳しなければ、私の四角形は表示されますが、急速に点滅しています。私がそれを翻訳すると、長方形は見えなくなりますか?あなたは解決策を知っていますか? – WeirdElfB0y