In the Game1 class Game1 in any XNA project, methods Game1 , LoadContent , UnloadContent , etc. are UnloadContent .

Also, there are variables GraphicsDeviceManager and SpriteBatch declared. In order to add the ability to draw through another class, you need to transfer the same SpriteBatch as one of the method parameters.

Next, in the method of the class we need, we refer to spriteBatch :

 public void Draw(SpriteBatch sprite) { sprite.Begin() ... } 

Is there a way to achieve an opportunity that would not require passing this argument as a parameter?

    1 answer 1

    Create a new spriteBatch object

      SpriteBatch spriteBatch = new SpriteBatch(game.GraphicsDevice); 

    where is game, there is an object of the game class inherited from Game, or you can send the crystals to the initialization of the GraphicsDevice sprite. Each class can have its own spritebatch, and each one can be drawn inside the other.

     sb1.begin() sb2.begin() sb2.end() sb1.end()