I'm using the InputHandler
's touchdown
method. It gives me my screenX
and screenY
. Is there a simple way to convert screenX and screenY to world coordinates? By my understanding, InputHandler
returns the coordinates in relation to your screen.
\$\begingroup\$
\$\endgroup\$
Add a comment
|
\$\begingroup\$
\$\endgroup\$
2
Sure.
Take your camera matrix and unproject it (or invert it). This can be done in libgdx like so:
Vector3 worldCoordinates = new Vector3(screenX, screenY, 0);
camera.unproject(worldCoordinates);
-
\$\begingroup\$ Ok thanks. It works exactly like I wanted it. Very useful information! \$\endgroup\$ – Patrick Jean Apr 7 '14 at 4:37
-
\$\begingroup\$ @PatrickJean If this answered your question, please accept it on the left hand side so other users can see this in the future. \$\endgroup\$ – Vaughan Hilts Apr 7 '14 at 4:40