I'm planning to make a simple soccerball app. When I attempt to drag the ball, I use the touchDragged() from InputProcessor to move the ball left or right. Next, while holding before releasing, I use the fling() from the GestureDetector to set the power. However, when I'm trying to set the input processor of both the implementing InputProcessor and the GestureDetector, it didn't work. Moreover, whenever the last time you set the input processor and that would be either the two of them. Why?


To be clear, you're calling:


twice? It just sets a global variable, so that's why only one sticks.

To support multiple input processors simultaneously, you want an InputMultiplexer. You can add multiple InputProcessor instances to the multiplexer and it will pass events to them in the order the processors were registered.

However, I think you'll still run into problems because both of your input processors are trying to "eat" the same input events (touch events). One of them will consume the events, leaving the other with nothing. Unless you can separate where on the screen each input processor owns (e.g., if the power-setting is a separate area of the screen from the soccer ball). Or, you could build your own multiplexer that knows which "mode" the game is in, and forwards events to the appropriate input processor. Its hard to say without more concrete information about your system.

| improve this answer | |
  • \$\begingroup\$ It's either to set a flag or in one of the methods under InputProcessor, it has to be set to false. \$\endgroup\$ – David Dimalanta Mar 11 '13 at 1:22

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.