Kevin Bryan
Kevin Bryan

Reputation: 1858

How to put Actors on top of each other?

How do you put Scene2d actors on top of each other?, I'm trying to make a photo gallery. I will add an Image actor to a Table then on the sides there are buttons for switching images. But adding actors to a table is a nightmare, you can't specify the location and most of all you can't add an actor on top of another actor. Is there a solution to this in Scene2d?

Upvotes: 1

Views: 318

Answers (1)

Sneh
Sneh

Reputation: 3737

As mentioned in the comment, try using the Stack class from Libgdx.

Simple example -

    Table root = new Table();
    Stack stack = new Stack();

    Table imageTable = new Table();
    //do stuff with table.

    Table buttonTable = new Table();
    //do stuff with button table

    stack.add(imageTable);
    stack.add(buttonTable); //button table will be placed exactly above imageTable

    root.add(stack);
    //do whatever you wanna do now with the root like adding on stage.

Upvotes: 1

Related Questions