Why do I have lines going across my libgdx game using Tiled?

删除回忆录丶 提交于 2019-12-03 07:33:31
noone

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!