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: AndroidStudio

Tiled (map editor): Tiled (map editor)

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

   public GameScreen(Game game){
      maploader = new TmxMapLoader();
      map = maploader.load("level1.tmx");
      renderer = new OrthogonalTiledMapRenderer(map, 1);

2 Answers 2


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.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .