我使用** Libgdx **,输入事件在使用**多操作系统引擎时不起作用**

时间:2016-12-12 07:13:48

标签: ios libgdx

它在Android和桌面上运行良好。但是在iOS上运行时,它不会响应任何输入事件。 我使用 gdxVersion 1.9.5 多操作系统引擎1.2.3 我写了一个测试类扩展输入适配器并覆盖touchDown和touchUp方法。但它并没有响应在Android中正常工作的任何输入事件。

public class TestScreen extends ScreenAdapter implements InputProcessor {

private CardGame game;
private OrthographicCamera guiCam;

public TestScreen(CardGame game){
    this.game = game;
    guiCam = new OrthographicCamera(Consts.WORLD_WIDTH, Consts.WORLD_HEIGHT);
    Gdx.input.setInputProcessor(this);
}

public void draw () {
    GL20 gl = Gdx.gl;
    gl.glClearColor(1, 0, 0, 1);
    gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    guiCam.update();
}

public void render (float delta) {
    draw();
}


@Override
public boolean keyDown(int keycode) {
    System.out.println("key down");
    return true;
}

@Override
public boolean keyUp(int keycode) {
    System.out.println("key up");
    return true;
}

@Override
public boolean keyTyped(char character) {
    System.out.println("key typed");
    return true;
}

@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
    System.out.println("touch down");
    return true;
}

@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
    System.out.println("touch up");
    return true;
}

@Override
public boolean touchDragged(int screenX, int screenY, int pointer) {
    System.out.println("touch dragged");
    return true;
}

@Override
public boolean mouseMoved(int screenX, int screenY) {
    System.out.println("mouse moved");
    return true;
}

@Override
public boolean scrolled(int amount) {
    System.out.println("scrolled");
    return true;
}
}

0 个答案:

没有答案