I want to flip my sprite horizontally while drawing and I can't figure out how to use the correct parameters without either an error or a warning about the method being obsolete.

This is what I assume it would be:

sb.Draw(NumbersGame.Arrow, resolutionRightArrow, Color.White, 

Except it comes up for errors for the color (cannot convert from color to rectangle) and the SpriteEffects bit (cannot convert from sprite effects to rectangle).

What is the correct way to lay out these arguments?

P.S: When I provide all the default values (says it's obsolete):

sb.Draw(NumbersGame.Arrow, resolutionRightArrow, null, null, null, 0f, null, 
Color.White, SpriteEffects.FlipHorizontally);
  • \$\begingroup\$ You can use Ctrl + Shift + Space to view the possible overloads of the selected line. That way you'll know which parameter to use. There's also a possible button for it in the toolbar, saying "Display Parameter Info" \$\endgroup\$ – Steven May 6 '19 at 6:33

Have you tried this overload?

public void Draw(Texture2D texture, Rectangle destinationRectangle, Rectangle? sourceRectangle, Color color, float rotation, Vector2 origin, SpriteEffects effects, float layerDepth);
  • \$\begingroup\$ What value do I need to use for layerDepth? -100, -1, 0, 1, and 100 don't work. \$\endgroup\$ – liaquore May 6 '19 at 20:36
  • \$\begingroup\$ It can range from 0 to 1f, try 0.5f for example \$\endgroup\$ – Silver May 7 '19 at 11:25
  • \$\begingroup\$ This answer could benefit from an explanation as to why this particular overload solves OPs problem. \$\endgroup\$ – bornander May 10 '19 at 5:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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