The boolean
value you return should be:
- true, if this
InputProcessor
or InputAdapter
handled the input.
- false, if it did not handle the input.
Think about a game, where 2 players play on the same pc (splitscreen for example).
One player controlls with "WASD", the second with "Arrow keys". So the InputProcessor
for the first player handles only the "WASD" keys and the InputProcessor
for the second only the "Arrow keys".
If the pressed key was "W,A,S or D", the first InputProcessor
handles it and you don't need to give it to the second one. So you return true
. If the pressed key is one of the "Arrow keys", the first InputProcessor
won't handle it and so you return false.
The multiplexer gets this return value and says:
- The return is
true
, input was handled, throw it away.
- The return was
false
, input not handled, give it to the next processor.
Hope you understand what i am talking about :P
Edit: the keyDown(int keyCode)
, keyUp(int keyCode)
and other methods have the int keyCode
, which tells you whihc key was pressed. Usually you use a switch to know which key was pressed. This switch looks like this:
switch(keyCode) {
case Keys.W:
// Handle the event for "W" key pressed
case Keys.A:
// Handle the event for "A" key pressed
// Other cases
default:
return false;
}
return true;
For your other question in the comment: If 1 player is controlled by W,A,S,D he does not need to handle the input for other keys. So he returns false, if he did not handle the input and true otherwise.
The second player is controlled by the arrow keys, so he does not need to handle other keys, like the W, A, S or D key.
If you have more then one InputProcessor
, which have to handle the same keys, you have to return false, so that the InputMultiplexer
passes the event to every InputProcessor
.