我是Libgdx的新手,我一直在寻找一种方法来改变文本按钮中的文字大小,但我找不到任何方法。我该怎么办呢。
scale_colour_grey()
答案 0 :(得分:2)
使用FreeTypeFontGenerator设置字体,然后更新按钮:
private void UpdateButton(float xf, float width, float height) {
if (xf > grayButton.getX() + grayButton.getWidth() / 2) {
width += 20;
height += 20;
} else {
width -= 20;
height -= 20;
}
params.size = (int) ((int) width / 4.0);
fontB = generator.generateFont(params);
grayButtonStyle.font = fontB;
grayButton.remove();
grayButton = new TextButton("abcABC", grayButtonStyle);
grayButton.setSize(width, height);
grayButton.setPosition((screenWidth - width) / 2, (screenHeight - height) / 2);
grayButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
UpdateButton(Gdx.input.getX(), grayButton.getWidth(), grayButton.getHeight());
}
});
stage.addActor(grayButton);
}