Libgdx Touchinput Gives Strange Numbers For Position On The Screen
Solution 1:
The only thing I can think of is that you screen size is not what you think it is - are you possibly mixing that up with having defined your Camera to view a 408x272 region? Is the size of the window on the screen actually 408x272 pixels?
If this is the issue, you need to do - assuming you are using an OrthographicCamera
:
Vector3v3=newVector3(screenX, screenY, 0);
cam.unproject(v3);
This will set the v3.x
and v3.y
to what you are looking for.
If this is not the issue, I'd try to make sense of how the strange positions are related to the expected ones - does it behave like the screen was larger? Is it flipped? If you manage to observe that, it might be easier to figure out.
Solution 2:
A lot of people will use Vector3 for storing touch points and will use Gdx.input
to get X and Y coordinates. Checkout Superjumper for more details, specifically the updateRunning
function.
Post a Comment for "Libgdx Touchinput Gives Strange Numbers For Position On The Screen"