Dominic K
Dominic K

Reputation: 7075

Content Manager in another class XNA

I have created a separate class (let's call it class2.cs for example) and want to use it as a level, in that when I call it, it will draw everything in one level for me. I'm having trouble getting contentmanager to work in class2. In the given Game1.cs, you can easily just go texture2d= Content.Load<Texture2D>("photo"); but I can't in class2.

I realize I have to create a new Content Manager, but it's constructor requires a game service, in which I'm not sure what I'm suppose to plug in. I currently have: ContentManager content = new ContentManager(); but I need an overload for ContentManager.

Upvotes: 2

Views: 6935

Answers (1)

smelch
smelch

Reputation: 2543

Pass Content to the constructor of your second class from the game, or you can create a Globals.cs class with static variables for your ContentManager or spriteBatch or any common resources.

Upvotes: 4

Related Questions