Jump to content
  • Advertisement
Sign in to follow this  
blackpenny15

[.net] MDX 1.1 Horizontal sprite flipping

This topic is 4088 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
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.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!