Search code examples
javalibgdx

libGDX : change Scroll position of scroll pane


In my code the y scroll position in pixels is the top of the scroll pane :

    stage = new Stage(new StretchViewport(480, 800));
    Image map = new Image(new Texture(Gdx.files.internal("assets-levels/map.png")));
    scrollpane = new ScrollPane(map, new ScrollPaneStyle());
    scrollpane.setFillParent(true);
    stage.addActor(scrollpane);

    Gdx.input.setInputProcessor(stage);

How can I change y scroll position in the bottom of scroll pane ?


Solution

    1. Create a class named MyScrollPane which would be copied from ScrollPane.
    2. Add this line myScrollpane.amountY = map.getHeight();