FitViewport

FitViewports 是始終保持縱橫比的視口。它通過在剩餘空間的邊緣上建立黑條來實現此目的。這是最常用的視口之一。

用法:

private Viewport viewport;
private Camera camera;

public void create() {
    camera = new OrthographicCamera();
    viewport = new FitViewport(80, 48, camera);
}

public void resize(int width, int height) {
    viewport.update(width, height);
}