libgdx coordinate system differences between rendering and touch input

前端 未结 4 1757
我在风中等你
我在风中等你 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条回答
  •  萌比男神i
    2021-02-08 02:40

    To detect collision I use camera.unproject(vector3). I set vector3 as:

    x = Gdx.input.getX();     
    y = Gdx.input.getY();
    z=0;
    

    Now I pass this vector in camera.unproject(vector3). Use x and y of this vector to draw your character.

提交回复
热议问题