Last Updated: January 28, 2019
·
3.393K
· drabiter

Easy Screen Scaling on LibGdx

@Override
public void resize(int width, int height) {
    stage.setViewport(PREFFERED_WIDTH, PREFFERED_HEIGHT, true);
    stage.getCamera().translate(-stage.getGutterWidth(), -stage.getGutterHeight(), 0);
    if (table != null){
        table.setSize(PREFFERED_WIDTH, PREFFERED_HEIGHT);
    }
}

Don't forget set Table#setFillParent to false.