So I understand that a Stack is used to overlay things on top of each other, but is it possible to sandwich something in between a Table? For example, let's say I build my main menu using a Table, but after the UI is built, I want to place a full-screen overlay right underneath my play button. How can I achieve this? Here's a simple sketch of what I'm looking for:

enter image description here

The problem I'm facing is that, even if I use a Stack, the button that I want to place on top of the overlay has to be a separate entity apart from the Table I want it to be a participant of, so I can't place it within the underlying Table's structure.

  • \$\begingroup\$ Why don't you just disable, don't draw the unwanted buttons at all or make another table? \$\endgroup\$ – Madmenyo Jul 16 '17 at 20:58

You should use the built-in z-index ordering of Actors. For z-ordering to work the Actors have to have the same parent. This can be kind of tricky to do without messing up the positioning and you have to do it in a kind of "hack-y" way by using an Image as your overlay like this:

// Add to table BEFORE changing z index!
table.addActor(overlay); // addActor not add!

overlay.setFillParent(true); // Fill entire table important!

button1.setZIndex(3); // On top of overlay
overlay.setZIndex(2); // Overlay
button2.setZIndex(1); // Below overlay
button3.setZIndex(0); // Below overlay
  • Why addActor? The reason we use addActor instead of add is so we can add the overlay to the table without messing up the position of the other children.
  • Why add before zIndex? zIndex works by re-ordering the children of the actor's parent. If there are no children it cannot be re-ordered.
| improve this answer | |

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.