Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

In Microsoft.Xna.Framework.Graphics.SpriteEffects there is the possibility to flip a texture horizontally or vertically before rendering. But can one do both at the same time?

When I use: spriteEffect = SpriteEffects.FlipHorizontally | SpriteEffects.FlipVertically; with spriteEffect being a parameter of the particle. The method spriteBatch.Draw(spriteSheet, currentPositionForDraw, sourceRectangle, currentColorMultiplied, currentRotation, currentOriginForDraw, Temp.delta, spriteEffect, 0); does not draw the particle flipped on both axis.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

Yes. If you look at the definition of that enum you'll see it has [FlagsAttribute] which means you can combine the enum values with the | operator.

share|improve this answer
    
Sorry, but how do I do that ? –  pad_ares Jan 13 '13 at 18:35
    
SpriteEffects.FlipHorizontally | SpriteEffects.Flipvertically –  Adam Jan 13 '13 at 18:43
    
I edited my question. –  pad_ares Jan 13 '13 at 18:50
    
@pad You edited the question to suggest that this answer is insufficient, but it's still marked as correct. Which is it? –  Anko Jan 14 '13 at 4:27

If you don't care about rotation, you can simply set the origin of the sprite to its center and rotate it 180 degrees (Math.PI). This is the same as flipping horizontally and vertically.

If you do care about rotation, and the sprite is flipped both ways, you can just add Math.PI to the angle and you should be done (eg. 45 degrees + 180 degrees rotation looks the same as 45-degrees flipped on both axes).

share|improve this answer
    
+1 for an interesting alternative –  andrew Jan 13 '13 at 21:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.