Java LibGDX InputProcessor Multi Touch

时间:2016-08-24 15:31:42

标签: java android libgdx

for (int i = 0; i < 20; i++) {
    if (Gdx.input.isTouched(i)) {
        player1.touchPosition = new Vector3(Gdx.input.getX(i), Gdx.input.getY(i), 0);
        camera.unproject(player1.touchPosition);
    }
}

它正在运行,但我想将InputProcessor与touchDragged事件一起使用。

如何将此代码转换为InputProcessor?

1 个答案:

答案 0 :(得分:0)

   public boolean touchDragged(int screenX, int screenY, int pointer) {
    if (pointer < 20) {
                player1.setTouchPosition(new Vector3(Gdx.input.getX(pointer), Gdx.input.getY(pointer), 0));
                camera.unproject(player1.getTouchPosition());        }
    return true;
}