[.net] MDX 1.1 Horizontal sprite flipping

Started by
1 comment, last by blackpenny15 16 years, 11 months ago
Hi guys, erm i need a bit of help, im my efforts to recreate mario in MDX 1.1, i can't figure out how to flip my sprite, im using the sprite.Draw() method, i can't find much in the way of how to do it. please please please help, i understand i should be doing a transform with a matrix or something?, thanks si
Advertisement
I had a problem with vertical flipping a while ago, the thread is here. Take a look at the last post.

What's import is the order of matrix operations, scale first and then translate. I also found that you have to translate yourself and pass DirectX.Vector3.Empty to the draw call, or Direct3D will reset the matrix.
just incase anyone else has this problem, i did the following, set up a property for my sprite class to i knew if it was left or right facing.

if (theSprite.spriteLeft)
{
mSprite.Transform = Matrix.Scaling(-1f, 1.0f, 1.0f);
//mSprite.Transform = Matrix.Multiply(mSprite.Transform, Matrix.Translation(300f, 90f, 0f));
}
else
{
mSprite.Transform = Matrix.Scaling(1f, 1.0f, 1.0f);
//mSprite.Transform = Matrix.Multiply(mSprite.Transform, Matrix.Translation(0f, 0f, 0f));
}

however this seems to flip it from 0.0f so we need to do the following while we render:

mSprite.Begin(SpriteFlags.AlphaBlend);
if(theSprite.spriteLeft)
mSprite.Draw(theSprite.Texture, theSprite.SourceRectangle, new Vector3(23.0F, 0.0F, 0.0F), new Vector3(-theSprite.SpriteX, 0.0F, 0.0F), Color.White);
else
mSprite.Draw(theSprite.Texture, theSprite.SourceRectangle, new Vector3(0.0F, 0.0F, 0.0F),new Vector3(theSprite.SpriteX, 0.0F, 0.0F), Color.White);
mSprite.End();


hope this helps anyone in the same mess, also if this is totaly wrong please tell me where so i can make my engine just a little bit better, thanks guys.

si

This topic is closed to new replies.

Advertisement