I use FitViewport in my libGDX game. it works perfectly on Android & Desktop, but I just can't get it right on iOS.
the pink box contains the game screen & the black parts are just black like that
this is how I initialize the important elements
camera = new OrthographicCamera(MenuScreen.VIRTUAL_WIDTH,
MenuScreen.VIRTUAL_HEIGHT);
viewport = new FitViewport(MenuScreen.VIRTUAL_WIDTH,
MenuScreen.VIRTUAL_HEIGHT, camera);
viewport.apply();
camera.position.set(camera.viewportWidth / 2,
camera.viewportHeight / 2, 0);
b = new SpriteBatch();
b.setProjectionMatrix(camera.combined);
MenuScreen.VIRTUAL_WIDTH & HEIGHT are 480 & 800
and this is my resize method:
@Override
public void resize(int width, int height) {
renderer.getViewport().update(width, height);
renderer.camera.position.set(renderer.camera.viewportWidth / 2,
renderer.camera.viewportHeight / 2, 0);
renderer.getB().setProjectionMatrix(renderer.getCamera().combined);
}
and I am sort of stressed as my license is expiring soon & cannot renew it anymore at RoboVM :S