我使用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();是否可以调整纹理或TextureRegion的大小?什么是最好的方法?
发布于 2014-07-09 12:36:08
我的has问题已经用以下代码解决了:
windowTryAgain.add(buttonMenu).width(100).height(100);
然后,图像将根据细胞的宽度和高度调整大小。
演职人员:
https://stackoverflow.com/questions/24652854
复制相似问题