Is it possible to 'mix n match' SpriteBatch.Draw()'s parameters?

Hello,

I’m wondering if there is any way to create a customised SpriteBatch.Draw() call with parameters of your own choosing?

My current draw call is spriteBatch.Draw(MyImage, Vector2.Zero, Color.White); What I want to do is rotate this image without having to worry about all the other parameters that form part of the more elaborate calls to SpriteBatch.

As it is If I want to rotate the image I need to handle at least an additional 4 or 5 parameters.

So to clarify, what I’d like to be able to do is SpriteBatch.Draw(MyImage, Vector2.Zero, float rotation, Color.White); and change the value of rotation during Update() as you normally would.

Is this possible? If so, how would I go about it.

Thanks.

You could do:

spriteBatch.Draw(
    texture: playertex,
    position: Vector2.Zero, 
    color: Color.White,
    rotation: 1f);
1 Like

For more information, see C# named parameters.

Thanks, Guys.

Exactly what I wanted.

I wasn’t even aware that any sort of named parameter functionality was present in C#, my coding skills are a bit rusty at the moment.