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);
}