syclone :
I'm trying to get the coordinates in the entire game. But when I call Gdx.input.getX()
or Gdx.input.getY()
, it only gives the screen coordinates and not the coordinates in the entire game.
I have tried this method:
private Vector3 mouse_position = new Vector3(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), 0);
mainCamera.unproject(mouse_position);
System.out.println(mouse_position.x + " " + mouse_position.y);
... but this gives a totally false coordinates. I think I'm missing something here.
Both these methods are used in my render()
method if that matters.
Genhis :
You need to pass current mouse position and then unproject it using camera.
Vector3 mouse_position = new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0);
mainCamera.unproject(mouse_position);
System.out.println(mouse_position.x + " " + mouse_position.y);
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=324404&siteId=1