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 have an enum in my game that denotes the game state ie MainMenu, InGame, GameOver, Exit and I was wondering if it would be advisable to add a new one in for PrepGame - in which the game creates viewports for however many players there are, creates the battlefield etc.

I feel like this is a good idea except for one thing: should I make a call back to LoadContent() in this state? I could just put a switch statement in the LoadContent for my currentGameState. If it equals PrepGame load things like the skybox, ship models, texures, HUD graphics etc. Or is it a good idea to create an Asset Manager class in the first call to LoadContent() and load everything then.

I feel like both approaches have different benefits: faster, but more load times vs slower initial load time, but then all my objects are referencing the same variables so I only have to load each on once.

Any help is greatly appreciated.

Thanks, Peter

share|improve this question

1 Answer 1

If you write down the SWITCH-statement into LoadContent there will be no actions you expect, because LoadContent is invoked only one time - during the initialization. I thing that in LoadContent you should load only resources which common for every game state & level. But it will be good to create methods like LoadContentForLevel1(), LoadContentForLevel2() & others for special states and call it in your state-dependent code.

PS sorry for my english :)

share|improve this answer
    
I though load content could be called multiple times? For example with a windows phone when the game is suspended then resumed because of a call or something. –  ClassicThunder Dec 16 '12 at 0:19
    
I was also talking about explicitly calling the LoadContent function when I load a level. –  Peteyslatts Dec 16 '12 at 4:02
    
I don't know exactly. MSDN says that "This method is called by Initialize. Also, it is called any time the game content needs to be reloaded, such as when the DeviceReset event occurs. You should not access the GraphicsDevice until LoadContent is called. LoadContent is called by Initialize, and before Draw. During the time the code for this method is executing, the user will experience a delay before the initial game screen appears." –  Oles Dec 16 '12 at 14:24

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.