Reputation: 1783
I am programming a small game and it's based on tiles. But when I render it, sometimes a small space between those tiles is visible and the (green) background is exposed (as can be seen in the video).
Youtube video (the green lines are appearing)
I was wondering, if there is some double-buffering technique, which could solve this bug, but I've read, that double-buffering is already implemented.
Upvotes: 1
Views: 386
Reputation: 1783
This was my final solution:
for(Body b : bodies) {
b.setTransform(Math.round(b.getPosition().x*C)/C, Math.round(b.getPosition().y*C)/C, 0);
}
Running this after loading and creating blocks from Tiled solved the problem. Since few of the blocks had position (for example) 9.99999999 or 9.00000001, rounding them solved it.
Upvotes: 1
Reputation: 19776
Please have a look at this forum thread I made long time ago. I've posted my solution as an answer there.
It is basically due to not having any padding in between your tiles, so sometimes, due to rounding, you will hit exactly in between two tiles and this is why the background gets rendered. The solution is to add padding to your tiles as described in the forum thread, using one of the old libgdx tools.
Upvotes: 1