Question

I'm using LibGdx and Tiled and when moving around the screen, there are both horizontal and vertical lines appearing on the game. I can post any code you need, if necessary. How do I get these lines to stop?

Still image of said lines

Here's a gfycat gif of the lines:

http://gfycat.com/FastUnnaturalAmericanwirehair

Edit:

Here's a small bitbucket repository, as small as I could get it that has the same glitch in it:

https://bitbucket.org/Chemical_Studios/example-of-line-glitch/src/8eeb153ec02236d836763072611bd7aa55d38495/minimalExample/src/com/weebly/chemicalstudios/minEx/?at=master

Was it helpful?

Solution

This is because you need to add a padding to your tiles.

This is a pretty common problem and you are not the first to encounter it. Basically due to rounding errors when scaling and panning around, sometimes you will render the area "between" two tiles, which will result in nothing being rendered -> black background colour comes through.

You basically need to use some tools to add the padding to your tileset. In this forum thread I explained how to do it.

There is also one more questions regarding this topic on stackoverflow here.

OTHER TIPS

When you have rounding errors you can always force the number to snap to the grid you want. In my case that looked like this:

gameCam.position.x = (float) Math.round(player.b2body.getPosition().x * 100f) / 100f;

Because I used a pixels-per-meter constant of 100f throughout the game, to scale everything

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top