# Is there a simple way to flip a Sprite?

### Question

• It's been a while since I've posted here (last question I asked was about scrolling a 2D background) and now I'm back with another 2D question.

Is there a simple way to flip a sprite horizontally and vertically? I started to just make new textures for each of the positions, but then I thought somebody has to know how to do this the right way for 2D games.

From what I'm gathering, typically you do some kind of World transformations to flip your game objects around when you normally develop for DirectX (and by normal I mean 3D development), but with the 2D development route I've been going, I've been trying to leave out things like World and Camera (other than what the native classes like Sprite, create and use on their own in the background).

Any input, suggestions or links to examples would be appreciated. I did some searches tonight, but the examples I keep turning up all seem to involve textured quads and world transformations and I'm hoping it's not going to take all that just to make Pac-Man face the other direction.

Thursday, April 06, 2006 6:02 AM

• Just read the teture backwards.

If you are using the Sprite class you just pass in the opposite corner and a negative rectangle

e.g.

normal:  PointF(x,y), SizeF(w, h)

flip-horiz: PointF(x+w, y), SizeF(-w, h)

flip-vert: PointF(x, y+h), SizeF(w, -h)

Thursday, April 06, 2006 5:21 PM

### All replies

• Just read the teture backwards.

If you are using the Sprite class you just pass in the opposite corner and a negative rectangle

e.g.

normal:  PointF(x,y), SizeF(w, h)

flip-horiz: PointF(x+w, y), SizeF(-w, h)

flip-vert: PointF(x, y+h), SizeF(w, -h)

Thursday, April 06, 2006 5:21 PM
• Well, don't I feel foolish...

Thanks for the nice simple answer! I'm glad it was just that easy.
Thursday, April 06, 2006 6:21 PM