Add handling keyboard for move pointer
This commit is contained in:
parent
1d71f35627
commit
cab5006bb6
@ -1,6 +1,7 @@
|
|||||||
package com.annimon.influencexxii;
|
package com.annimon.influencexxii;
|
||||||
|
|
||||||
import com.badlogic.gdx.InputProcessor;
|
import com.badlogic.gdx.InputProcessor;
|
||||||
|
import com.badlogic.gdx.Input;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Input handling by keyboard or touch
|
* Input handling by keyboard or touch
|
||||||
@ -8,9 +9,28 @@ import com.badlogic.gdx.InputProcessor;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class InputHandlingProcessor implements InputProcessor {
|
public class InputHandlingProcessor implements InputProcessor {
|
||||||
|
|
||||||
|
private Pointer pointer;
|
||||||
|
|
||||||
|
public InputHandlingProcessor(Pointer pointer) {
|
||||||
|
this.pointer = pointer;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyDown(int keycode) {
|
public boolean keyDown(int keycode) {
|
||||||
|
int horizontal = 0;
|
||||||
|
if (keycode == Input.Keys.LEFT) horizontal--;
|
||||||
|
else if (keycode == Input.Keys.RIGHT) horizontal++;
|
||||||
|
|
||||||
|
int vertical = 0;
|
||||||
|
if (keycode == Input.Keys.UP) vertical--;
|
||||||
|
else if (keycode == Input.Keys.DOWN) vertical++;
|
||||||
|
|
||||||
|
if ( (horizontal != 0) && (vertical != 0) ) {
|
||||||
|
pointer.update(horizontal, vertical);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user