LibGDX - Coordinate Issue with Gdx.input.istouched

Hi there,

I’m having quite the issue at the moment. When I run my game on the desktop, if I click a rectangle it works… however on the android, the rectangle is in a different position, yet the img is normal.
(Please don’t recommend stages, actors, etc. I’m using spritebatch, cameras, textures, and rectangles for startup purposes.)

Thanks!

  • A

So whats the problem?

Is the rectangle being created and rendered at a different position on the screen as the image? Try rendering the rectangle on the screen to see it’s position.

Did you set the projection matrix of the spritebatch and shaperenderer correctly? You should post your code so we can see, but I have a feeling you don’t have the touch coordinates and screen coordinates set properly for the different screen resolution your android device might have.

[quote=“syszee,post:1,topic:51182”]
I don’t get the question. What rectangle do you click, and how does that rectangle relate to “the” img? If you want help put some effort in explaining what the question is, because this does not make sense.

Did you set up the viewport to maintain the same aspect ratio across multiple devices? Your phone will have a different aspect ratio than your monitor, so the coordinate system will be different unless you explicitly set up the camera to handle the differences.