Archive for the ‘XNA’ Category

I’ve constructed a primitive batch based on the Microsoft and Farseer examples that can apply a texture to a 2D polygon.

Texture configuration properties are stored in the ‘user data’ property in the Farseer Body and Fixture objects.

I use the body position to determine the texture coordinates. This allows you to apply rotation and translation to the texture coordinates based on the body, in addition to the stored properties.

As you can see, the textures can be applied across multiple sub fixtures.

alphaEditor_03

XNA Development – Turnip Toss

Posted: December 27, 2012 in .NET, XNA
Tags: , ,

Working on a XNA game I am currently calling “Turnip Toss” using the Farseer physics engine.

The editor is in early alpha stages now.
2 dimensional “bodies” and simple shapes can be created by right clicking a position on the editing surface.

alphaEditor_01

alphaEditor_02

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! =^]