How to draw Texture from class?

I am completely new to this, and I’m curious as to how to draw my texture 2D from Game1.cs the following is my Player.cs

It’s pretty easy since you already have a SpriteBatch instance passed to your Draw function. You first let spriteBatch know that you’re gonna start drawing stuff, then you draw it, then you tell spriteBatch you’re done. SpriteBatch has a bunch of overloads on the Draw function for things like scale, rotation, mirroring your sprite, color to multiply the texture with, area of the texture to draw, area to draw to and depth. If you don’t need all that you can just draw the player with only the texture, the position and a color (there’s no overload without the color, but you can pass white to not change the color of the texture). In code that will look like this:

spritebatch.Begin();
spriteBatch.Draw(playerTexture, playerPosition, Color.White);
spritebatch.End();

Awesome thank you. Then in my Game1 class all I need to do is put Player.Draw right?

Yup, that’s right :slight_smile:

Well, in your game class you have to initialise the player. In the draw method in the game class just say :
spritebatch.Begin();
player.Draw(spriteBatch)
spritebatch.End();

Create a Draw method in Player and get the spritebatch parameter and place this in it :
spritebatch.Begin();
spriteBatch.Draw(playerTexture, playerPosition, Color.White);
spritebatch.End();

I hope I could help : ) !

I appreciate everyone’s help. I managed to get it figured out :slight_smile: