Home:ALL Converter>how to flip a sprite in c#

how to flip a sprite in c#

Ask Time:2011-05-27T07:45:50         Author:Zanrkvil

Json Formatter

I'm making a little game based on XNA game development's tutorial game "shooter"... after a bit of trial and error, I made my own animated sprite that i can move around the screen. The problem is, he's always facing right.

How can i change this (image below) so that he faces the right direction every time the key event is pressed?!

I'm pretty new to C# as you might have guessed, and I realize this may be more complicated than i thought, so i just need to know how to make the sprite face right when moving right and left when he's moving left.

image

Thank you in advance.

Author:Zanrkvil,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/6146337/how-to-flip-a-sprite-in-c-sharp
Bryan :

You can also do this by passing the SpriteEffects.FlipHorizontally option to yourSpriteBatch.Draw() method. But as others have said this will have more overhead than using a sprite sheet.",
2011-05-26T23:59:31
Ed S. :

Usually a sprite sheet will contain images for each direction. You can flip the image at runtime, but it adds image processing that is unnecessary. I would suggest to you that you simply create a sprite sheet up front with each animation baked in and just figure out which frame to display at runtime.\n\nSee an example of a simple sprite sheet here",
2011-05-26T23:49:46
yy