0
\$\begingroup\$

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

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

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 :)

\$\endgroup\$
3
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Dec 16, 2012 at 0:19
  • \$\begingroup\$ I was also talking about explicitly calling the LoadContent function when I load a level. \$\endgroup\$ Commented Dec 16, 2012 at 4:02
  • \$\begingroup\$ 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." \$\endgroup\$ Commented Dec 16, 2012 at 14:24

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.