基本绘制方法 BlenddState 无法识别?
我非常擅长编程,但是,我是 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的第一个想法是:如果将鼠标悬停在错误上会发生什么?它应该为您提供一个工具提示,其中的文本告诉您实际的错误是什么。
此外,如果您的源文件顶部没有
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 ofBlendState.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.