Draw Method [SOLVED]

I use this template for a sprite class:

public class{
Texture2D texture;
public class(Texture2D texture)
this.texture = texture;
public void Draw(spriteBatch sp)
sp.Draw(texture, new Vector 2(0, 0), Color.White);

PROBLEM : sp.Draw is limited just to (texture, position/rectangle, color). If I try to do sp.Draw(texture, position, color, SpriteEffect.None, 0.1f); it gives this error: No overload for method ‘Draw’ takes 5 arguments

You’ve got two options in C#…

  1. Supply all parameters for the overload you want. There’s no overload that does what you want exactly. Right-click Draw and select “go to definition” to see which one you can use.
  2. Use the C# parameter short-hand. I think it’s something like:
variable.Method(paramName: paramValue, ...);

You might have to google that last one :slight_smile:

Side note, I notice you have a Begin and End call inside your sprite draw. Just calling your attention to it… you really only wanna begin/end a new sprite batch if you’re changing some effects or other parameters, otherwise you want to try to do all your drawing inside of a single begin/end block. You may want to consider moving those calls out and doing all your sprite draws in between.

You might also consider making a “Layer” object that holds references to many sprites, then that layer can control the spritebatch begin and end.

Just something to be aware of :slight_smile:

1 Like

Thx :slight_smile: