【问题标题】:XNA Spritebatch.End() with Class doesn't work when startedXNA Spritebatch.End() with Class 在启动时不起作用
【发布时间】:2014-06-04 00:44:58
【问题描述】:

XNA spritebatch.End();一个类不起作用,它说:'XNA Framework Reach profile requires TextureAddressMode to be Clamp when using texture size that are not the power of two.'开始时。它也没有显示任何错误。我该如何解决这个问题?请帮忙!!

 public override void Draw()
    {
        Statics.SPRITEBATCH.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, null,null);

        Statics.SPRITEBATCH.Draw(this.background, Vector2.Zero, Color.White);

        foreach (var item in Tuyaux)
        {
            item.Draw();
        }

        Statics.SPRITEBATCH.Draw(this.sand, new Vector2(0, 529), Color.White);

        Scroll.Draw();

        Bird.Draw();

        Statics.SPRITEBATCH.DrawString(this.Font, "Score : " + this.score.ToString(), new Vector2(10, 10), Color.Red);

        if (Bird.dead)
        {
            // rode gloed over het spel als het gameover is.
            Statics.SPRITEBATCH.Draw(Statics.PIXEL, new Rectangle(0,0, Statics.GAME_WIDTH,Statics.GAME_HEIGHT), new Color(1f, 0f, 0f, 0.3f));
            // gameover achtergrond laten zien.
            Statics.SPRITEBATCH.Draw(this.gameover, new Vector2(0, 80), Color.White);
        }

        Statics.SPRITEBATCH.End(); 
        base.Draw();
    }

【问题讨论】:

  • “同课”是什么意思?我很确定确实,您只需要使用 2 次方的纹理大小,因为您针对 Reach 配置文件进行编译并且不使用 Clamp! this.backgroundthis.sandStatics.PIXEL(我希望是 1x1)和 this.gameover 的尺寸是多少?我怀疑您在自己的Draw 方法中绘制到相同的SpriteBatch... 也检查那里使用的纹理。异常准确地说明出了什么问题;-)

标签: c# xna


【解决方案1】:

问题正是异常告诉你的:

您的目标是 Reach 配置文件,因此您的所有纹理尺寸必须是 2 的幂,或者您必须使用钳位作为地址模式。所以:

  • 如果您不需要包装,请尝试在您的 Statics.SPRITEBATCH.Begin 通话中将 SamplerState.LinearWrap 替换为 SamplerState.LinearClamp
  • 如果您需要包裹纹理,请确保所有纹理的尺寸都是 2 次方
  • 最后但同样重要的是,如果您可以选择,您可以简单地使用HiDef 配置文件而不是Reach

【讨论】:

    猜你喜欢
    • 2023-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多