4
\$\begingroup\$

In my level Menu, I am using tables that have images and text to identify each game level. Those tables are in a table that is inside a ScrollPane so the player can browse the levels available.

Here is how i've written the code:

//top of my show() method

    stage = new Stage();

    Gdx.input.setInputProcessor((com.badlogic.gdx.InputProcessor) stage);

    atlas = new TextureAtlas("levelsmenu/levelmenu.pack");

    skin = new Skin(Gdx.files.internal("levelsmenu/liststyle.json"), atlas);



//example of the tables with image and text identifying each level

    tableLevel1 = new Table();
    tableLevel1.add(new Image(skin, "rhlevelone"));

    tableLevel1.add(new Label("THE HOOD", skin));


//table with the levels available

    Table levelList = new Table(skin);
    levelList.add(tableLevel1);
    levelList.row();
    levelList.add(tableLevel2);
    levelList.row();
    // etc.

// ScrollPane

    scrollPane = new ScrollPane(levelList, skin);

// 
table3.add(scrollPane).padLeft(220).expandY();

//
stage.addActor(table3);

On the stage I have a button to go back to the Main Menu and a button to play the level selected.

I would like to request help to figure out how to set the right listeners so a level can be selected in the ScrollPane and then played cliking the Play Button.

Should I use FocusListener or ClickListener?

Here is an illustration of what I want do do: enter image description here

Thanks in advance for any help that may come!!!

Rich Days

\$\endgroup\$
3
\$\begingroup\$

This is the logic:

  • Create ImageButtons or TextButtons first
  • Add these to a Table
  • Create a ScrollPane with the Table
  • Set ScrollPane position and size. You can disable scrolling in a direction using scrollPane.setScrollingDisabled()
  • Add ScrollPane to the Stage
\$\endgroup\$
-1
\$\begingroup\$

Try using ChangeListener, i've never used a ScrollPane but I did some UI's using ChangeListener!

\$\endgroup\$
  • 2
    \$\begingroup\$ This answers needs some additional meat. More implementations details, pseudo-code, or something. Right now your advice is too vague to be useful. \$\endgroup\$ – Seth Battin May 19 '15 at 23:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.