Add handling keyboard for move pointer

This commit is contained in:
Victor 2014-01-14 22:48:34 +02:00
parent 1d71f35627
commit cab5006bb6

View File

@ -1,6 +1,7 @@
package com.annimon.influencexxii;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.Input;
/**
* Input handling by keyboard or touch
@ -9,8 +10,27 @@ import com.badlogic.gdx.InputProcessor;
*/
public class InputHandlingProcessor implements InputProcessor {
private Pointer pointer;
public InputHandlingProcessor(Pointer pointer) {
this.pointer = pointer;
}
@Override
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;
}