libgdx coordinate system differences between rendering and touch input

前端 未结 4 1700
我在风中等你
我在风中等你 2021-02-08 01:50

I have a screen (BaseScreen implements the Screen interface) that renders a PNG image. On click of the screen, it moves the character to the position touched (for testing purpo

4条回答
  •  有刺的猬
    2021-02-08 02:48

    I had same problem , i simply did this.

    public boolean touchDown(int screenX, int screenY, int pointer, int button) {
    
        screenY = (int) (gheight - screenY);
        return true;
    }
    

    and every time you want to take input from user dont use Gdx.input.getY(); instead use (Gdx.graphics.getHeight()-Gdx.input.getY()) that worked for me.

提交回复
热议问题