首页 > 解决方案 > 当 sourcerect 准确时,C# spritesheet 显示相邻的图块

问题描述

好的,所以我的问题是:这显示了精灵表上不存在的图块之间的小轮廓

我尝试在 spritesheet 上的图块之间添加一个空间,它只是将相邻图块的轮廓更改为边缘的稍微轻一点的版本,我认为它是抗锯齿的,但我的 spritebatch.Begin 是:

spriteBatch.Begin(SpriteSortMode.FrontToBack, null, SamplerState.PointClamp, null, null, null, Main.cam.Completetransformation() * Main.DrawScaling);

SpriteBatch.Begin 在基础 Draw() 中被调用,Image.Draw() 是 spriteBatch.Draw() 被调用的地方

我的 Image 类运行如下:

                        Image.LayerDepth = layerDepth;
                        Image.Position = tile.position;
                        Image.SourceRect = tile.SourceRect;
                        Image.Color = tile.Color;

                        Image.Draw(spriteBatch);

和 Image.Draw(SpriteBatch spriteBatch):

        public void Draw(SpriteBatch spriteBatch)
        {
                origin = Vector2.Zero;
                spriteBatch.Draw(Texture, Position, SourceRect, Color * Alpha, 0.0f, origin, Scale, SpriteEffects.None, LayerDepth / 100);
        }

我用谷歌搜索了不同的 spritebatch 开始模式等,但我不知道我错过了什么,SourceRect 始终为 32 * 32(等于图块大小),我没有发现位置问题,所以我完全没有想法

编辑:我也有

            Graphics.PreferMultiSampling = false;
            Graphics.ApplyChanges();

在我的 Initialize()

标签: c#monogame

解决方案


推荐阅读