1
\$\begingroup\$

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);
\$\endgroup\$
2
\$\begingroup\$

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.

\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ Each image is 21x21 and that's what I'm using on Tiled (with 2px for margin and spacing) \$\endgroup\$
    – sok
    Oct 10 '15 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 '15 at 16:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.