Solved Mouse Position in Zoomed Tile Map

Hello,

I’m wondering how to get the X and Y of the mouse, but scaled for a tile map. Specifically, I am zoomed in at 15f and 9f ratio with my orthographic camera.

Please supply a simple code example of getting the correct coordinates based on the tile map.

Thanks

Can you clarify what you’re trying to do? “Scaled for a tile map” can mean a lot of different things.

No, read my reply here to find out why .

@Gibbo3771 , don’t you think I would do that first? I did that but nothing good game up. I figured I’d fall back on a good community that should be supportive. If you don’t feel like helping, just don’t respond.

@boxsmith , scaled using an orthographic camera in LibGDX. I was able to do this using Gdx.input.getX() / 54… but I don’t think this will work with screen re-sizing.

Your first mistake is using orthographiccamera directly. Try Viewports.

Oh I’ll help, what I won’t do is write it for you, which is what you’re basically asking.

@syszee Please read the Libgdx Wiki or at least the relevant parts.
In your case the Viewport and it’s unproject-method would be the thing to use.

@Springrbua , yea the unproject method is what I’ve been seeing a lot of. I just do not know how to properly use it for getting the coordinates and then using them within an upscaled (camera setToOrtho) version…

The unproject-method is easy to use: Give it your touchposition and you will get the world-position. The camera itself allready knows, that it is zommed, so it should take care about that and you should get the real world-point.