Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am trying to load up a single SpriteFont to print some debug information. In our current game, we load up both Textures and Music through a ResourceManager. They are both loaded with a filestream, and thus do not require Content.Load

SoundEffect soundEffect = SoundEffect.FromStream( fs );

Since this ResourceManager does not inherit from Game or is like Game.cs, I cannot use the usual method:

SpriteFont spriteFont = Content.Load<SpriteFont>(resource.Key.Item2);

Anyone have any idea how I can either: -Load the SpriteFont a different way -Create my own Contentmanager

share|improve this question
1  
Just send Content as parameter to the other class? This is generally how it's made. If you have a scene class(for example, not necessarily) you usually pass content (or entire game) as parameter to the class creator. So you can create your resources in there. –  Gustavo Maciel Mar 21 '12 at 4:35

1 Answer 1

up vote 1 down vote accepted

You could do what Gustavo - Gtoknu said and pass the content manager variable into your ResourceManager class OR you could create a new content manager. You'd have to have a reference to your main game class, but this is the idea:

ContentManager content = new ContentManager(myGameRef.Services, "Content");

Where "Content" is the root directory to load content from.

Keep in mind that when the content variable is disposed, so are all the resources associated with it (ie. anything you loaded), so you want to keep it in scope until you're done with the resources it loaded.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.