如何消除平铺纹理之间的间隙? [英] How to remove gaps between tiled textures?
问题描述
我正在使用LibGDX制作平台游戏.我在平台上使用方形砖,但绘制它们时,其中一些之间存在间隙.当我放大/缩小或在间隙周围移动相机时移动位置.
I'm using LibGDX to make a platformer. I'm using square tiles for the platforms but when they are drawn some of them have gaps between them. When I zoom in/out or move the camera around the gaps move position.
更多详细信息:
- 标题是32x32,我已经尝试了32x32和64x64.
- 磁头以32个像素隔开(例如,第一个磁贴为x = 0 y = 0,第二个磁贴为x = 32 y = 0,依此类推,在x和y方向上都是如此).
- 间隙不是我检查过的纹理假象.
- 我将
TexturePacker
与填充一起使用.
- Tiles are 32x32 and I have tried both 32x32 and 64x64.
- Tiles are lined up 32 pixels apart (e.g. first tile would be x=0 y=0, second x=32 y=0, and so on in both x and y directions).
- The gaps are not texture artifacts as I have checked this.
- I use the
TexturePacker
with padding.
我的最佳猜测是将纹理转换为屏幕坐标时存在问题,但不知道如何解决此问题,我找不到任何解决方案.我已经检查并仔细检查了瓷砖尺寸并对齐了它们的精度.
My best guess is that it is a problem when converting the textures to screen coords but have no idea how to fix this and I couldn't find any solution. I have checked and double-checked my precision with tile sizes and lining them up.
有人遇到过同样的问题,或者知道如何解决吗?
Has anyone had the same problem or know how it fix it?
推荐答案
我通过将TexturePacker.Settings
类的duplicatePadding
字段设置为true
来解决此问题.
I got it fixed by setting the duplicatePadding
field of the TexturePacker.Settings
class to true
.
示例代码:
import com.badlogic.gdx.tools.texturepacker.TexturePacker;
import com.badlogic.gdx.tools.texturepacker.TexturePacker.Settings;
Settings settings = new Settings();
settings.maxWidth = 1024;
settings.maxHeight = 1024;
settings.duplicatePadding = true;
TexturePacker.process(settings, "source", "destination", "name");
这篇关于如何消除平铺纹理之间的间隙?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!