Sign in to follow this  

[.net] MDX 1.1 Horizontal sprite flipping

This topic is 3875 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

This topic is 3875 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this