GriffinBabe GriffinBabe - 1 year ago 123
Java Question

Java LibGDX: How to get a map based coordinate system?

I'm making a 2D isometric tiled game using LibGDX. In my Player class, I created a vector2 that I named 'pos' to manage the player position, then I draw my Player with:


Let's say pos = (0,0), then the Player will be rendered at the bottom left corner of my screen.

When I translate the camera, the (0,0) still correspond with the bottom left of my screen, so the pos Vector2 is about my screen, not my map...

What should I do to get a Coordinate System based on the map and not on my screen? I would not prefer using the Sprite Class...

Thank you :)

Answer Source

Basim Khajwal was right,

calling batch.setProjectionMatrix(camera.combined) works perfectly :)

However if you are looking for a deeper comprehension you can also read this article here:

Where "view position" is your screen position and "model position" is your map position.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download