LibGDX TextureRegion draw bug when using split method and scaling

401 views Asked by At

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.

2

There are 2 answers

0
vedi0boy On BEST ANSWER

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.

7
Gerard Abello On

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.