【发布时间】:2014-05-11 15:43:00
【问题描述】:
我不知道是不是只有我,但drawables 让我很困惑。他们是打算保持给定的大小,还是有办法在其中缩放图像?我知道他们可以使用 Ninepatch 通过拉伸图像来填充某些区域,但我想缩放它拉伸的图像。我正在使用TextButton 对于我的菜单按钮,但它们太大了,我很想知道如何缩放它们。我正在从地图集中检索皮肤,其中包含九个补丁图像。 这是设置屏幕: 这是我正在使用的包中的图像: 下面是 TextureAtlas 和 Skin 的初始化:
buttonAtlas = new TextureAtlas(Gdx.files.internal("buttons/buttons.pack"));
buttonSkin = new Skin(buttonAtlas);
这是该菜单按钮的初始化。
TextButtonStyle textButtonStyle = new TextButtonStyle();
textButtonStyle.up = Assets.buttonSkin.getDrawable("bluebutton");
textButtonStyle.down = Assets.buttonSkin.getDrawable("redbutton");
textButtonStyle.font = font;
buttonMenu = new TextButton("Menu", textButtonStyle);
buttonMenu.pad(20.0f);
buttonMenu.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.fade.startFadeOut();
super.clicked(event, x, y);
}
});
也许我可以改变我把它放在桌子上的方式,或者我把桌子放在舞台上的方式?
table.add(buttonMenu).width(Gdx.graphics.getWidth()/4);
stage.addActor(table);
作为最后的手段,我想我可以尝试创建自己的可以缩放的文本按钮 actor,感谢您抽出宝贵时间。
【问题讨论】:
标签: android button libgdx scaling scene2d