我正在尝试在舞台上以虚拟16:9大小显示标签:
public class MyGdxGame extends ApplicationAdapter {
private Stage stage;
@Override
public void create () {
stage = new Stage(new FillViewport(16, 9));
Label label = new Label("What's wrong with labels?",
new Label.LabelStyle(new BitmapFont(), Color.WHITE));
label.setBounds(0, 0, 16, 9);
stage.addActor(label);
Gdx.input.setInputProcessor(stage);
}
@Override
public void render () {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.act();
stage.draw();
}
@Override
public void dispose () {
stage.dispose();
}
}
字体看起来很大,无法适应屏幕范围:
然后我尝试设置字体缩放和自动换行:
stage = new Stage(new FillViewport(16, 9));
Label label = new Label("What's wrong with labels?",
new Label.LabelStyle(new BitmapFont(), Color.WHITE));
label.setBounds(0, 0, 16, 9);
label.setFontScale(0.1f);
label.setWrap(true);
stage.addActor(label);
完全搞砸了:
尝试设置视口大小(以像素为单位),如1080:1920。在这种情况下,标签显示为小,如预期的那样。但我想让我的世界大小(16:9)与标签一起使用。你能建议我如何正确缩小字体吗?