Fish
Fish

Reputation: 1697

Libgdx - How can I split the screen for different input processors in each part

I have used "CameraInputController" and "Touchpad" which is contained in a stage to move my camera, and move my character, respectively.

However, I have encountered a problem. I use InputMultiplexer like this to set both processors.

    InputMultiplexer multiplexer = new InputMultiplexer();
    multiplexer.addProcessor(camController);
    multiplexer.addProcessor(stage);

    Gdx.input.setInputProcessor(multiplexer);

Now the problem is when I move the touchPad, the camera also moves. That is annoying to the player.

Therefore I want a method to have different input processors in different parts of the screen.

Upvotes: 1

Views: 658

Answers (1)

Quallenmann
Quallenmann

Reputation: 323

I think it will solve by change the order of the InputAdapter.

multiplexer.addProcessor(stage);
multiplexer.addProcessor(camController);

Because the Stage will now be the first to handle the input events and if you return true the camController won't be handled after that. See InputMultiplexer Wiki for a little more Information.

Upvotes: 3

Related Questions