Ersen Osman
Ersen Osman

Reputation: 7247

LibGDX: Scene 2D Table, Is it possible to overlap two actors like an image and a label?

The image below explains what I want to do.

The top diagram represents how I have the arrangement now.

The bottom diagram represents how I want the arrangement. Here is a diagram:

enter image description here

I wish for a label actor to be on top of an image actor.

Can this be done?

Upvotes: 3

Views: 1058

Answers (1)

Ersen Osman
Ersen Osman

Reputation: 7247

Thanks to @noone for guiding me to the stack. Please note my code is apart of a scroll pane. Also note the last item to be added to the stack will be on top. So that's why I add image and then the label.

Image image = new Image(texture);
Label buildingName = new Label(entry.getValue.name, skin, "building");
buildingName.setAlignment(Align.top);     
Stack stack = new Stack();  
stack.add(image);
stack.add(buildingName);
stack.addListener(buildItemUIListener); //used for click listener
stack.setName(entry.getKey()); //Used for the click listener 
table.add(stack);

Upvotes: 7

Related Questions