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
  • \$\begingroup\$ Check out the documentation for right call for the method Draw() it shows multiple overload options. docs.microsoft.com/en-us/previous-versions/windows/xna/… \$\endgroup\$
    – J-ho
    Oct 11 '20 at 13:17
  • \$\begingroup\$ What is the overload you have used that did work, without the horisontal flipping? \$\endgroup\$ Sep 24 at 20:14

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
  • 1
    \$\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

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .