XNA Platformer Parralax Tutorial Problem

Posted: May 15, 2011 in .NET, XNA
Tags: , , ,

While following the scrolling tutorial for the XNA Platformer Starter Kit (3.1), I ran into an issue with the Level.Draw() method. This problem only occurs if you are using XNA 4.0 or higher with the tutorial.

In the tutorial (http://msdn.microsoft.com/en-us/library/dd254919(v=xnagamestudio.31).aspx) it has the line –

spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None, cameraTransform);

But this fails, as the SpriteBatch.Begin() signature and SpriteBlendMode Enum has changed in XNA 4.0.

Instead, use the following line (or pass in NULL(s) for default parameter options.

spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullCounterClockwise, null, cameraTransform);

Example Passing in NULLs –

spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, null, cameraTransform);
 

Hopefully this will save someone a a few minutes! =^]

Advertisements
Comments
  1. Voyager says:

    Hey, did you get the whole script to work on XNA 4.0?
    I need some help with it. Can you help me? Email me preferably.

  2. mikeylow says:

    thank you so much for this post, saved me quite some time 😉

  3. toggit says:

    Thanks for this!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s