Search code examples
javalibgdxscene2d

Imagebutton one on top of another can't click the one underneath the other - Scene2d LIBGDX


I have two ImageButtons one on top of the other. Depending on events in my game I fadeOut one of the buttons and fadeIn the other, and vice versa. The problem is that the buttons are placed in a Stack at exactly the same position and the button underneath does not receive the click event. How can I temporarily stack it on top of the other one that is fadedOut so it receives the click event?


Solution

  • You can use the toFront() method of Actor. Then it should receive the events.