I have a problem with multiple stages and listeners in libGDX. I have GameScreen with gameStage (contains game elements), uiStage (score label and pause button) and pauseStage (resume, restart and exit buttons).

And I have InputMultiplexer to which I add pauseStage, uiStage and anonymous listener in constructor. In result when user touches pause button, game stops and pause buttons appears on the screen. When he touches screen in other place, it's handled as control of the game character.

But there is a problem - when playing, I don't draw pauseStage but still when I click in the area when buttons from pauseStage would be if they were visible, this click is not handled. I tried a lot of ways but it's not working. How to "pause" pauseStage buttons listeners while playing or do something to make pauseStage invisible?pauseStage.getRoot().setVisible() isn't working...

  • \$\begingroup\$ You say you are not drawing the pause stage. So you cannot expect the buttons of that stage that are not being drawn and handled to work, right? Am I misunderstanding something? \$\endgroup\$ – Madmenyo Jul 21 '15 at 12:09
  • \$\begingroup\$ My comment above is actually only true if you don't call pauseStage.act(deltaTime). I think buttons should be handled when you are calling that line but not drawing the stage with pauseStage.draw(). \$\endgroup\$ – Madmenyo Jul 21 '15 at 12:13
  • \$\begingroup\$ So what are you actually calling? And what do you exactly want? To me it sounds like you want to have invisible buttons to work, that sound counter intuitive to me. \$\endgroup\$ – Madmenyo Jul 21 '15 at 12:15
  • \$\begingroup\$ I want the buttons to work only if they are visible. I have if and call .act() only when state is "paused". \$\endgroup\$ – bpawel10 Jul 21 '15 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.