LibGDX - 具有固定比例的缩放图像

Mar*_*ius 4 layout android libgdx

我的LibGDX游戏有一个带有徽标和一些按钮的开始屏幕.我无法弄清楚如何以固定的比例缩放徽标以免扭曲它.

那是代码:

public StartScreen(int lastScore, InputListener inputListener) {
    super();
    this.listener = inputListener;
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);

    Table table = new Table();
    table.setFillParent(true);
    table.setBackground(new TextureRegionDrawable(new TextureRegion(new Texture(Gdx.files.internal("background.png")))));

    Image imageLogo = new Image();
    imageLogo.setDrawable(new TextureRegionDrawable(new TextureRegion(new Texture(Gdx.files.internal("title.png")))));

    // Here's the problem, the image is not scaled correctly...
    table.add(imageLogo).center().colspan(2);
    table.row();

    // Some Buttons
    table.add(button1).colspan(2).padBottom(30);
    table.row();
    table.add(button2).padBottom(30);
    table.add(button3).padBottom(30);
    table.row();
    table.add(button4).colspan(2);

    stage.addActor(table);

    //table.debug();
}
Run Code Online (Sandbox Code Playgroud)

Mar*_*ius 6

我发现你可以使用它与图像 - 工作正常!

imageLogo.setScaling(Scaling.fit);
Run Code Online (Sandbox Code Playgroud)