# How do I properly load maps?

I'm trying to load my map properly, but it takes some time (after the games has been started) to be how it should. Am I doing something wrong? Why is this happening?

AndroidStudio:

Tiled (map editor):

public class GameScreen extends Screen{
private TiledMap map;
private OrthogonalTiledMapRenderer renderer;

public GameScreen(Game game){
renderer = new OrthogonalTiledMapRenderer(map, 1);


This is a common problem caused by using floating point numbers for your camera movement. Occasionally, you will see the spaces between tiles. There are two ways you can counteract this:

1. Round your camera position up to whole integers. This will make camera transitions look less smooth however.
2. Give each tile in your tileset a padding of 1px on each side, and in Tiled, when you add a new Tileset, set the Margin to 1px and Spacing to 2px.

Logically, you would expect each tile to line up correctly without the need to do this. I am unsure if this is a problem with the way libGDX handles TiledMap rendering or not.

I face this problem often. That annoying lines are there because when you import the tileset in Tiled you're selecting a wrong tile size. For example, you're saying Tiled that your tiles are 33x32 (when they are 32x32), or you've not adjusted correctly the margins... Check out your "import" tileset configuration to ensure it fits your image.

Also, make sure the tile size of your imported tileset is the same as the map tilesize.

• Each image is 21x21 and that's what I'm using on Tiled (with 2px for margin and spacing)
– sok
Oct 10 '15 at 16:31
• The problem could be caused by another thing, but all the times I found it it was due to my configuration in Tiled. Oct 10 '15 at 16:38