0
votes

I'm currently with no idea of what's going on with libGDX (Android only) today... I have my beautyfull table, with buttons and some other stuff, and I added the ScrollPane to scroll (Obviously), then I added everything inside other table and changed the size values to the center of the screen, scaled, etc. And now the ScrollPane isn't working...

buttonsTable = new Table();
buttonsTable.center().center();
// adding buttons and buttons and more buttons...
ScrollPane scroller = new ScrollPane(buttonsTable);
scroller.layout();
scrollableTable = new Table();
scrollableTable.center().center();
scrollableTable.add(scroller);
this.stage.addActor(scrollableTable);

// SIZE_WIDTH and SIZE_HEIGHT are the size of my screen
scrollableTable.pack();
scrollableTable.setTransform(true);
scrollableTable.setScale(0.5f,0.5f); // I changed the scale of the table(1/2)
scrollableTable.setPosition(SIZE_WIDTH/2 - scrollableTable.getWidth()/4, SIZE_HEIGHT/2 - scrollableTable.getHeight()/4); 
// It doesn't update its height and width, so I just divide by 2 and by 2 again to go to the center

The table is in the center of my screen, but now the ScrollPane is 'broken'...

OBS: I called stage.act(Gdx.graphics.getDeltaTime()) inside render() and Gdx.input.setInputProcessor(stage); inside the Screen's constructor.

1
There are more buttons inside the table than the quantity of buttons that the screen is able to show - user5427813
As I'm Brazilian and my native language isn't english, if someone wants to correct me somehow, I would appreciate! - user5427813
Make sure you're using Gdx.input.setInputProcessor(stage); - Abhishek Aryan
@AbhishekAryan I'm calling this method. I will add it to the question. - user5427813

1 Answers

0
votes

I tested a ScrollPane that scroll :

public class TestClass extends ApplicationAdapter {

    Stage stage;
    ExtendViewport extendViewport;

    @Override
    public void create() {

        extendViewport =new ExtendViewport(640,400);

        stage=new Stage(extendViewport);
        Skin skin=new Skin(Gdx.files.internal("skin/glassy-ui.json"));

        Table scrollableTable = new Table();
        scrollableTable.setFillParent(true);
        stage.addActor(scrollableTable);

        Table table = new Table();
        table.add(new TextButton("WELCOME",skin)).row();
        table.add(new TextButton("TO",skin)).row();
        table.add(new TextButton("LIBGDX",skin)).row();
        table.add(new TextButton("GAMING",skin)).row();
        table.add(new TextButton("FRAMEWORK",skin)).row();
        table.pack();
        table.setTransform(true);  //clipping enabled

        table.setOrigin(table.getWidth()/2,table.getHeight()/2);
        table.setScale(.5f);

        final ScrollPane scroll = new ScrollPane(table, skin);
        scrollableTable.add(scroll).expand().fill();

        stage.setDebugAll(true);
        Gdx.input.setInputProcessor(stage);
    }

    @Override
    public void render() {

        Gdx.gl.glClearColor(0, 0, 0, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

        stage.draw();
        stage.act();
    }

    @Override
    public void dispose() {
        stage.dispose();
    }

    @Override
    public void resize(int width, int height) {
        stage.getViewport().update(width,height);
        stage.getCamera().position.set(320,200,0);
        stage.getCamera().update();
   }
}