LIBGDX: What is the meaning of the return value of InputAdapter keyDown, keyUp ... etc.

I'm having problems processing input from several separate InputAdapters that use keyDown / keyUp.

Gdx.input.setInputProcessor( new InputMultiplexer( keyboardController1, keyboardController2, keyboardController3));

Only the first in the line works, while the others do not; in this case keyboardController1. I guess this has something to do return true;with the end of the methods keyDown(). I tried reading documentation, tutorials, posts ... etc. But I still can not understand what the return value means and what, and to what logical values ​​I should set it. My question is: What is the meaning of the boolean return value of keyDown / keyUp (etc.)?

+4
source share
3 answers

The return value booleanshould be:

  • true if this InputProcessoror InputAdapterprocessed input.
  • false if it is not processing input.

, 2 (, splitscreen).
"WASD", - " ". , InputProcessor "WASD", InputProcessor - " ".
"W, A, S D", InputProcessor , . true. " ", InputProcessor , false.

:

  • true, , .
  • false, , .

, , : P

: keyDown(int keyCode), keyUp(int keyCode) int keyCode, , . , , . :

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;

: 1 W, A, S, D, . , false, . , , W, A, S D. InputProcessor, , false, InputMultiplexer InputProcessor.

+6

u , , , , , true;

else, , , u, false.

, u , . u , return true , else false.

+2

, ,

:

true , , , .

, , return false.

+1

Source: https://habr.com/ru/post/1534370/


All Articles