Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

libgdx

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?

like image 490
Ersen Osman Avatar asked Feb 01 '26 16:02

Ersen Osman


1 Answers

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);
like image 93
Ersen Osman Avatar answered Feb 04 '26 04:02

Ersen Osman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!