【发布时间】:2014-07-09 11:46:44
【问题描述】:
我正在使用 libgdx + scene2d + box2d。一切看起来都很好,直到我决定将我的 TextButtons 替换为 ImageButton。
我的 ImageButton 无法重新排列,它始终遵循图像尺寸。
这是我的舞台:
stage = new Stage(new StretchViewport(camera.viewportWidth,camera.viewportHeight));
这是如何创建我的按钮:
ImageButtonStyle style = new ImageButtonStyle();
style.imageUp = new TextureRegionDrawable(textureButtonPlay);
ImageButton buttonPlay = new ImageButton(style);
buttonPlay.setSize(50, 20); //this does not work
这是如何创建我的窗口并将我的按钮添加到它:
WindowStyle windowStyle = new WindowStyle(new BitmapFont(), Color.WHITE, null);
windowTryAgain = new Window("", windowStyle);
windowTryAgain.setMovable(false);
//windowTryAgain.padTop(20);
windowTryAgain.setSize(150,150);
windowTryAgain.setPosition(camera.viewportWidth/2 - windowTryAgain.getWidth()/2,
camera.viewportHeight/2 - windowTryAgain.getHeight()/2);
windowTryAgain.row().fill().expandX();
windowTryAgain.add(buttonPlay).padTop(25).expandX().fillX();
windowTryAgain.center();
是否可以调整 Texture 或 TextureRegion 的大小?最好的方法是什么?
【问题讨论】:
标签: libgdx