Problem managing the render order of an isometric tiled map with LibGDX.

Hello,

I have an Isometric Tiled Map and few Players I want to render with LibGDX. The problem is the render order, so the players can be seen behind or before walls, depending their positions.

I decided to create an ArrayList containing objects (RenderTiles and Players) and their priority, so everytime the game renders, it sorts the ArrayList with a priority variable and then renders the objects in the right order. I created an interface named Renderable that is implemented in the Player class and the RenderTile class.

public interface Renderable {
	
	public int getPriority(); //The priority on the screen's y axis, thats how I will sort my ArrayList
	public void render(SpriteBatch batch,char direction, int x, int y);  //direction is for the player only, not the tile

}

My problems are:

  • How do I render a single Tile with LibGDX, do you think batch.draw(tile.getTextureRegion(), x, y) works ? (tile is a TiledMapTile Object)
  • How do I get all the tiles from a Tiled Map Layer one by one? So I can create RenderTile objects and add them into my ArrayList
  • How do I sort my ArrayList with one value that all those objects share: int priority (I’m pretty new in programming)

I know these are a lot of questions but I can’t find the solution in the LibGdx doc…

Thank you :slight_smile: