0

I get a graphical glitch whenever I try to split my tileset into a TextureRegion[][] and drawing them. It works fine when I am using the default aspect ratio but when the window has to stretch, it seems to be accessing a line of pixels from the next tile in the tileset and drawing them. Here is a picture (The lines I am referring to are the 2 vertical brown lines in the water. They seem to be from another tile in my tileset):

The lines also move when I move the player. And when I run the game on my tablet, a similar effect happens except its the bottom layer of my player's feet that appear above its head.

I saw a similar problem in stackoverflow (stackoverflow.com/questions/285...) but the solution did not work for me. It said I should put a padding but that just makes the lines transparent and you see the background color.

Community
  • 1
  • 1
vedi0boy
  • 1,030
  • 4
  • 11
  • 32

2 Answers2

1

Here is the solution I found. Someone on stackoverflow asked a similar question and they got a working response. They made a tile bleeding fix method. Here is the post: White vertical lines and jittery horizontal lines in tile map movement

Credit to grimrader22. Thanks a lot!

Thanks everyone else who helped get me on the right track to getting the solution.

Community
  • 1
  • 1
vedi0boy
  • 1,030
  • 4
  • 11
  • 32
0

As you said, the usual solution is to add a padding.

The padding should be of the same color as the border of the tile. For example the water tiles should have a blue padding and the sand a yellow one.

That way you won't get the transparency and it will be seamless.

Hope it helps.

Gerard Abello
  • 658
  • 3
  • 7
  • For adding padding to your textures you can use the official [Texture-packer](https://github.com/libgdx/libgdx/wiki/Texture-packer) – Sebastian Jun 18 '15 at 12:24
  • Thanks for you help but I am not sure this will work well with more intricate tiles that are designed to fit together seamlessly. For sand and water it would be already but what about sandstone (darker sand in image). It has patterns that would be disrupted. Also, I am designing my game so that players can make their own tilesets and edit this one, doing something like this could get complicated for them. Would there be a way to convert the TextureRegions into Textures so there are no ties to the Tileset anymore? – vedi0boy Jun 18 '15 at 12:26
  • As Sebastian said, you can use the Texture packer of libgdx. It works also with patterns because it will copy the left edge as the left padding (and so on with all the sides), so the lines of background color you see now will still be there, but with pixels that match the pattern. – Gerard Abello Jun 18 '15 at 13:54
  • Well like I said I want to have support for community made tiles so I want to make it as simple as possible for other people. Thanks for your help. – vedi0boy Jun 18 '15 at 13:58
  • The texture packer can be used at runtime. You can have only the separated tiles in the assets folder and create the texture map with the padding when the program starts. – Gerard Abello Jun 18 '15 at 14:01
  • So they have to be in separate png files? – vedi0boy Jun 18 '15 at 15:12
  • 1
    Forgive me, I am being an idiot. Thanks for your suggestions, I will research the rest on my own, thanks for setting me on the right path. There is no need for you to do the research for me since this is my problem. Thanks again! :) – vedi0boy Jun 18 '15 at 17:30