Java StretchViewPort工作不正常

Java StretchViewPort工作不正常,java,libgdx,Java,Libgdx,我使用的虚拟视口大小为855*540 我的代码是 游戏中的屏幕 public void show() { gameStage=new GameStage(); //Constants.VIEWPORT_WIDTH=855; Constants.VIEWPORT_HEIGHT=540; gameStage.setViewport(new FillViewport(Constants.VIEWPORT_WIDTH, Constants.VIEWPORT_HEIGHT)

我使用的虚拟视口大小为855*540

我的代码是

游戏中的屏幕

 public void show() { 
    gameStage=new GameStage();
   //Constants.VIEWPORT_WIDTH=855;    Constants.VIEWPORT_HEIGHT=540;
    gameStage.setViewport(new FillViewport(Constants.VIEWPORT_WIDTH, Constants.VIEWPORT_HEIGHT));
    hudStage=new HudStage();
    hudStage.setViewport(new StretchViewport(Constants.VIEWPORT_WIDTH, Constants.VIEWPORT_HEIGHT));

}

 public void resize(int width, int height) {    
    Gdx.app.log("Gameplay", "in gameplay resize");
    gameStage.getViewport().update(width, height, false);
    hudStage.getViewport().update(width, height, false);            
}
在这个阶段

 public  HudStage(GameStage controller) {
    //virtual size
    int width=855;
    int height=540;

    Drawable imageUpAK=new TextureRegionDrawable(atlas.findRegion("ak_IconEnable"));

    ImageButton topButton= new ImageButton(imageUpAK, imageUpAK);
    topButton.setPosition(0,height*.8f);
    addActor(topButton);

    ImageButton buttonBottom= new ImageButton(imageUpAK, imageUpAK);    
    buttonBottom.setPosition(0,0);
    addActor(buttonBottom); 

    Label resolution=new Label(Gdx.graphics.getWidth()+"x"+Gdx.graphics.getHeight(), style);
    resolution.setAlignment(Align.right);
    resolution.setPosition(0,height*.45f);
    addActor(resolution);
 }
作为回报,我得到的响应以不同的分辨率显示在图像中

我的问题:-我是否得到了期望的结果?如果不是,我做错了什么。如果正确,我应该做什么来避免切割元素


我希望hud元件的位置应该像我的虚拟Scrrensize,即其他scrren分辨率中的*855X580


提前感谢。

预期结果?对期望的结果?我不知道你想要的结果是什么我希望hud元素的位置应该像我的虚拟SCRRESIZE一样,即其他scrren分辨率中的*855X580。无需剪切按钮等。在调整大小方法中,此行应为true:hudStage.getViewport.updatewidth,height,true;两种情况下的结果是相同的。视口高度是否等于580?