2

I am having strange artifacts on a tiledmap while scrolling with the camera clamped on the player (who is a box2d-Body).

Before getting this issue i used the linear filter for the tiledmap which prevents those strange artifacts from happening but results in Texture bleeding (i loaded the tiledmap straight from a .tmx file without padding the tiles).

However now i am using the Nearest filter instead which gets rid of the bleeding but when scrolling the map (by walking the character with the cam clamped on him) it seams like a lot of pixel are flickering around. The flickering results can get better or worse depending on the cameras zoom value. But when I use the "OrthoCamController" class from the libgdx-Utilities which allows to scroll the map by panning with the mouse/finger i don't get these artifacts at all. I assume that the flickering might be caused by bad camera-position values received by the box2d-Body's position. One more thing i should add here: The game instance runs in 1280*720 display mode while my gamecam renders only 800*480. Wen i change the gamecam's rendersolution to 1280*720 i don't get those artifacts but then the tiles are way too tiny.

Has anyone experienced this issue or knows how to fix that? :)

ChrizZz
  • 51
  • 2
  • 7

2 Answers2

2

I had a similar problem with this, and found it was due to having too small a decimal value for the camera position.

I think what may be happening is some sort of rounding with certain tile columns/rows in the tilemap renderer.

I fixed this by rounding to a set accuracy, like so:

camera.position.x = Math.round(player.entity.getX() * scalePosition) / scalePosition;

Experiment with various values, but I got it working by using the tile size as the scalePosition value.

jamiebuckley
  • 118
  • 7
1

About tilesets, I posted a solution here: Getting gaps between tiled textures with libgdx

I've been using that method with Tiled itself. You will have to adjust "margin" and "spacing" when importing tilesets in Tiled to get the effect working.

It's 100% working for me :)

Community
  • 1
  • 1
Nine Magics
  • 637
  • 2
  • 8
  • 17