我有一个TEXT按钮,我想将它通过90度旋转的屏幕上。旋转TEXT按钮与libgdx
出于某种原因,旋转的所有方法(旋转(),setRotationAngle()等)与TEXT按钮对象的产生密切相关不正常工作。
所以我实现了新的类扩展TEXT按钮和压倒一切的draw()方法:
@Override
public void draw(SpriteBatch batch, float parentAlpha) {
Matrix4 rotationMatrix = new Matrix4();
Matrix4 oldMatrix = batch.getTransformMatrix();
rotationMatrix.idt();
rotationMatrix.rotate(new Vector3(this.getX(),this.getY()+this.getHeight(),0),rotationAngle);
batch.setTransformMatrix(rotationMatrix);
super.draw(batch, parentAlpha);
batch.setTransformMatrix(oldMatrix);
}
凡rotationAngle
等于90.0。由于某种原因,按钮不会旋转90度,但是对于某些未知的度数。
UPD
后,我切换回TEXT按钮对象,做:
newGame.setTransform(true);
newGame.rotate(90);
它几乎工作意味着在按钮中的文本被corrently旋转,但背景留在它的按钮现货:
所以我的问题是:为什么会出现这种情况,我该如何解决这个问题?
旋转与其他载体没有帮助。但TextButton对象的方法setTrasform()帮助旋转按钮的文本,但不是按钮本身(P.S我已更新问题) –