缩放视口不在libgdx阶段中工作

时间:2017-10-25 11:54:08

标签: android libgdx viewport stage

我有一个简单的舞台,有一个按钮和3个单元格:

pauseStage = new Stage(screen.game.viewport);
Gdx.input.setInputProcessor(pauseStage);
pauseTable = new Table();
pauseTable.setFillParent(true);
pauseTable.debug();

Button.ButtonStyle musicBtnStyle = new Button.ButtonStyle();
musicBtnStyle.up = new TextureRegionDrawable(new TextureRegion((Texture)     this.screen.game.assetManagement.manager.get("MenuScreen/music_up.png")));
    musicBtnStyle.down = new TextureRegionDrawable(new TextureRegion((Texture) this.screen.game.assetManagement.manager.get("MenuScreen/music_down.png")));
    musicButton = new Button(musicBtnStyle);
    musicButton.addListener(new ClickListener()
    {
        @Override
        public void clicked(InputEvent event, float x, float y)
        {


        }
    });

pauseTable.row();
pauseTable.add().expandX();
pauseTable.add(musicButton).size(230f,230f);
pauseTable.add().expandX();

pauseTable.pack();
pauseStage.addActor(pauseTable);

screen.game.viewport被声明为viewport = new FitViewport(2560,1440, camera)。使用此代码,舞台渲染得很好。

not scaled viewvport

如果我使用的是缩放视口viewport = new FitViewport(25.6,14.4, camera),我将单元格大小从230更改为2.3 ...

pauseTable.add(musicButton).size(2.3f,2.3f);

......舞台渲染不正确。按钮和单元格被移位,如下所示:

scaled viewport

有谁知道,为什么它不能使用缩放视口?

0 个答案:

没有答案