Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

To be clear, you're calling:

Gdx.input.setInputProcessor(processorX);

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.

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.