我想在libgdx中旋转BitmapFont。这个问题已经有相关的话题。 Draw a BitmapFont rotated in libgdx 然而,我尝试的第一个解决方案截断了我的文本,整个文本没有出现(对角线割)。 它还将其旋转90度,而它应该是180度。 我真的不明白。
代码:
代码:
public void show() {
sr = new ShapeRenderer();
w = Gdx.graphics.getWidth();
h = Gdx.graphics.getHeight();
textRotation = new Matrix4();
textRotation.setToRotation( new Vector3(200,200, 0), 180);
rectThickness = h / 120;
c1 = Color.WHITE;
c2 = Color.WHITE;
f = new BitmapFont(Gdx.files.internal("fonts/MyFont.fnt"),
Gdx.files.internal("data/MyFont.png"), true);
f.setScale(h/500);
sb = new SpriteBatch();
}
private void renderPlayerScores() { //callend in render
sb.setTransformMatrix(textRotation);
f.setColor(players[0].getColor());
sb.begin();
f.draw(sb, "Player 1: "+ Integer.toString(scores[0]), 100, 110);
sb.end();
}