How to Implement TileMap in LibGdx ?

Step 1: Download TileMap Editor http://www.mapeditor.org

Step 2: Creating the game map

 Start up TileMap editor and choose “New map” in file menu. Enter a map size i.e screen size.

 I am using 32 x 32 (480 x 480) and tile size 16 X 16.

 Now choose “New Tileset” option in map menu.

Step 3: Now draw the map. TileMap editor works just like a pixel image editor .Save file with .tmx extension.(examle: level1.tmx)

Step 4: copy the .tmx file and tileset png in your assets/data folder ?

Step 5: just add code in create()

map* = new TmxMapLoader().load("data/level1.tmx");
renderer* = new OrthogonalTiledMapRenderer(map, 1 / 16f);

* TiledMap map;
* OrthogonalTiledMapRenderer renderer;



and render it on render() method

renderer.setView(camera);
renderer.render();

 

Post By:- Neha Agrawal