Jump to content
  • Advertisement
Sign in to follow this  
zuhane

Managing the ContentManager, SpriteBatch and GameTime (XNA)

This topic is 923 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey forum dwellers! Just had a few questions regarding memory management in XNA and it'd be great if I could get some clarification:

 

1.) Why would I bother passing the content manager into every single LoadContent method? Would it not be simpler to just make a single public static ContentManager which is used at the start when all the resources are loaded in? Surely it's only ever used once?

 

2.) The same applies for SpriteBatch and GameTime. I understand that there are ways to apply these in mixed fashions, but in a standard game that didn't try to use various game time and drawing applications, would it not just be simpler again to declare a single SpriteBatch and GameTime in, say, Game1, and make them both public static? Would this also reduce the amount of memory required?

 

3.) I've been using sprite sheet animations in my current game project, and the player's animation sheet is becoming huge. This is because I've tried to animate to accommodate 60fps, and the player also has many different poses and actions. Would it be better to separate the animations into multiple smaller PNG files, or keep this format? The player is actually rather tiny, and his sprite sheet is huge in comparison.

 

4.) Is it a good idea to use a static LoadContent method in certain situations? For example, say I have 100 enemies all loading this sprite sheet individually, if the sprite sheet was hypothetically 1MB in size, would this cause 100MB of textures to be loaded into the RAM? Would it then be smarter to load a single static texture that all enemies share, resulting in 1MB of memory usage being accessed instead?

 

 

 

 

Any help would be greatly appreciated :)

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!