我想要的是在更改屏幕尺寸時相應地更改大小的位圖字體。我的意思是在我的電腦上,字體顯得相當大,但在我的手機上,它是一種難以閱讀的小字體。我可以改變尺寸,但我希望它在所有屏幕上都看起來很相似,而不是在一個屏幕上顯示較大,而在另一個屏幕上顯示較小。這裏是我的代碼,看看我有什麼工作,並具:libgdx如何將BitmapFont縮放爲更改屏幕尺寸?
public void render() {
//score system
scoreFont.setColor(1.0f, 1.0f, 1.0f, 1.0f);
scoreBatch.begin();
scoreFont.draw(scoreBatch, Long.toString(getScore()), 10, Gdx.graphics.getHeight() - 10);
scoreFont.setScale(3, 3);
scoreBatch.end();
}
public void resize(int width, int height) {
camera.viewportWidth = 450;
camera.viewportHeight = 250;
camera.update();
stage.setViewport(450, 250, true);
stage.getCamera().translate(-stage.getGutterWidth(), -stage.getGutterHeight(), 0);
}
其實我找到了一個簡單的解決方案。我在render()和resize()方法中設置字體大小。我從render()方法中刪除了它 – Mercify