Gesture Detector not firing
- by Tyler
So I'm trying to create a input class that implements a InputHandler & GestureListener in order to support both Android & Desktop. The problem is that not all the methods are being called properly.
Here is the input class definition & a couple of the methods:
public class InputHandler implements GestureListener, InputProcessor{
...
public InputHandler(OrthographicCamera camera, Map m, Player play, Vector2 maxPos) {
...
@Override
public boolean zoom(float originalDistance, float currentDistance) {
//this.zoom = true;
this.zoomRatio = originalDistance / currentDistance;
cam.zoom = cam.zoom * zoomRatio;
Gdx.app.log("GestureDetector", "Zoom - ratio: " + zoomRatio);
return true;
}
@Override
public boolean touchDown(int x, int y, int pointerNum, int button) {
booleanConditions[TOUCH_EVENT] = true;
this.inputButton = button;
this.inputFingerNum = pointerNum;
this.lastTouchEventLoc.set(x,y);
this.currentCursorPos.set(x,y);
if(pointerNum == 1) {
//this.fingerOne = true;
this.fOnePosition.set(x, y);
}
else if(pointerNum == 2) {
//this.fingerTwo = true;
this.fTwoPosition.set(x,y);
}
Gdx.app.log("GestureDetector", "touch down at " + x + ", " + y + ", pointer: " + pointerNum);
return true;
}
The touchDown event always occurs but I can never trigger Zoom (or pan among others...). The following is where I register and create the input handler in the "Game Screen".
public class GameScreen implements Screen {
...
this.inputHandler = new InputHandler(this.cam, this.map, this.player, this.map.maxCamPos);
Gdx.input.setInputProcessor(this.inputHandler);
Anyone have any ideas why zoom, pan, etc... are not triggering?
Thanks!