首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ImageButton - Scene2d

ImageButton - Scene2d
EN

Stack Overflow用户
提问于 2014-07-09 11:46:44
回答 1查看 817关注 0票数 0

我使用libgdx + scene2d + box2d。一切看起来都很好,直到我决定把我的TextButtons换成ImageButton。

我无法对我的ImageButton进行重新定位,它总是遵循图像的尺寸。

这是我的舞台:

代码语言:javascript
复制
        stage = new Stage(new StretchViewport(camera.viewportWidth,camera.viewportHeight));

这是如何创建我的按钮:

代码语言:javascript
复制
    ImageButtonStyle style = new ImageButtonStyle();
    style.imageUp =  new TextureRegionDrawable(textureButtonPlay);
    ImageButton buttonPlay = new ImageButton(style);
    buttonPlay.setSize(50, 20); //this does not work

这是如何创建我的窗口并将我的按钮添加到其中:

代码语言:javascript
复制
    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的大小?什么是最好的方法?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-07-09 12:36:08

我的has问题已经用以下代码解决了:

windowTryAgain.add(buttonMenu).width(100).height(100);

然后,图像将根据细胞的宽度和高度调整大小。

演职人员:

scene2d button scaling with libgdx

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24652854

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档