【发布时间】:2012-05-12 18:15:18
【问题描述】:
我有一个基于图块的游戏。每个瓦片纹理都被加载,然后我将每个瓦片贴在一起绘制,形成一个连续的背景。我实际上是按照这个教程来获取 xml 文件的。
http://www.xnadevelopment.com/tutorials/looksleveltome/looksleveltome.shtml
纹理的来源是 50x50。
但是,它只有在比例为 1(或更低)时才有效,如果比例更大
结果:正常大小(50 像素和比例 1) http://imageshack.us/photo/my-images/525/smallzp.jpg/
更大的尺寸(在 xml 文件中放大或 100 像素) http://imageshack.us/photo/my-images/577/largeki.jpg/
我们可以看到瓷砖之间有线条,这些线条不在纹理中。这里实际上并没有那么糟糕,但是在我的游戏图块中,它就是这样做的: http://imageshack.us/photo/my-images/687/zoomedsize.png/
无论我在 xml 文件中增加 tile 大小、在绘图时更改比例还是使用我的相机进行缩放,都会出现相同的效果。
//zoom code
public Matrix GetTransformation()
{
return
Matrix.CreateTranslation(new Vector3(-_pos.X, -_pos.Y, 0)) *
Matrix.CreateRotationZ(Rotation) *
Matrix.CreateScale(new Vector3(Zoom, Zoom, 1)) *
Matrix.CreateTranslation(new Vector3(_device.Viewport.Width * 0.5f, _device.Viewport.Height * 0.5f, 0));
}
//draw
_spriteBatch.Begin(SpriteSortMode.Immediate,
BlendState.AlphaBlend, null, null, null, null,
_camera.GetTransformation());
//for each tile
theSpriteBatch.Draw(mSpriteTexture, Position, Source,
Color.Lerp(Color.White, Color.Transparent, mAlphaValue),
mRotation, new Vector2(mSource.Width / 2, mSource.Height / 2),
Scale, SpriteEffects.None, mDepth);
这是有原因的吗?有一种方法可以在缩放时将其修复为具有连续纹理?
【问题讨论】: