开发者

Basic draw method blenddstate not recognized?

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 definat开发者_开发技巧ely bothering me.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜