0

我有一张 512x512 的图像,需要平铺作为背景。

我通过SamplerState.LinearWrap在图像上设置和设置更大的源矩形来做到这一点。

spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, SamplerState.LinearWrap, DepthStencilState.Default, RasterizerState.CullNone);
spriteBatch.Draw(texture, bounds, bounds, Color.White);
spriteBatch.End();

boundsnew Rectangle(0, 0, 1024, 768)

现在它看起来像这样:

游戏背景

这些线是平铺图像的位置。原始 png 的边缘没有任何线条(我放大并在 Photoshop 中检查了它)。

这是怎么回事? 这是 DropBox 上的示例项目

我尝试使用非二次幂纹理,但它在SamplerState.

4

1 回答 1

2

似乎是图像中的图形工件。

我将图像的一部分复制并粘贴到边缘,它按预期工作,您的代码正在工作。尝试使用不同的图像进行确认。

于 2012-04-25T16:19:29.733 回答