Don't use the polling mechanism for input (Gdx.input.isXXX(...)
). It is not very stable because you might miss some events and it is also framerate dependent.
Implement an InputProcessor
for your gameplay input as well. Then use InputMultiplexer
to let both processors (Stage
and your GameplayInputProcessor
) have a chance to handle the events.
This should look like the following:
InputMultiplexer multiplexer = new InputMultiplexer();
multiplexer.addProcessor(stage);
multiplexer.addProcessor(gameplayInputProcessor);
Gdx.input.setInputProcessor(mutliplexer);
This way your stage will get the events first. In case you don't want your second processor to receive the input events if your UI already handled them, then you need to return true
in the handling methods of the stage.