基本绘制方法 BlenddState 无法识别?

发布于 2024-09-14 23:42:20 字数 629 浏览 2 评论 0原文

我非常擅长编程,但是,我是 C# (xna) 的新手,我正在按照教程在屏幕上绘制精灵,并且在绘制方法中使用时无法识别 BlendState 方法:

protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // TODO: Add your drawing code here
            // Draw the sprite.
            spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend); 

//doesnt recognize Blendstate(在其下面画上波浪线)

            spriteBatch.Draw(myTexture, spritePosition, Color.White);
            spriteBatch.End();

            base.Draw(gameTime);
        }

提前致谢,因为这肯定让我烦恼。

I am pretty good at programming, however, i am new to c# (xna), i am following a tutorial to draw a sprite on screen and the blendstate method is not recognized when used like the following in the draw method:

protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // TODO: Add your drawing code here
            // Draw the sprite.
            spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend); 

//doesnt recognize blendstate (puts squiggles under it)

            spriteBatch.Draw(myTexture, spritePosition, Color.White);
            spriteBatch.End();

            base.Draw(gameTime);
        }

thanks in advance as this is definately bothering me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

樱花细雨 2024-09-21 23:42:20

我的第一个想法是:如果将鼠标悬停在错误上会发生什么?它应该为您提供一个工具提示,其中的文本告诉您实际的错误是什么。

此外,如果您的源文件顶部没有 using Microsoft.Xna.Framework.Graphics(但您已经有 Microsoft.Xna.Framework.Graphics。 dll 被项目引用,你也需要它),它还会给你一个小框,点击添加到 using 语句中(我相信弹出它的快捷键是 Ctrl-Shift-F10)。

您也可以只传递 null 而不是 BlendState.AlphaBlend,因为这是默认的混合状态(请参阅 文档)。


我的第二个想法是您正在将 XNA 4.0 教程与旧版本的 XNA 一起使用。你是? 这篇博文解释了 SpriteBatch 中的差异。

My first thought is: What happens if you mouse-over the error? It should give you a tool-tip with the text telling you what the actual error is.

Additionally, if you haven't got using Microsoft.Xna.Framework.Graphics at the top of your source file (but you have got Microsoft.Xna.Framework.Graphics.dll referenced by the project, which you also need), it will also give you a little box to click to add in that using statement (I believe the shortcut key to make it pop up is Ctrl-Shift-F10).

Also you could just pass in null instead of BlendState.AlphaBlend, as that is the default blend state (see the documentation).


My second thought is that you're using an XNA 4.0 tutorial with an older version of XNA. Are you? This blog post explains the differences in SpriteBatch.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文