Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am creating a game using Visual Studio and trying to add the game state management example. I have added all the files from the example into my game but need to add in something to make it run the menu before the game starts. Any ideas on what I need to add, I've hit a blank.

share|improve this question
Hi and welcome to gamedev. You should be more specific about what "game state management example" you're referring to. Also you're not really clear about what the problem is. – bummzack Dec 13 '11 at 11:06
welcome to SE, take time to read to get help – Noob Game Developer Nov 14 '12 at 6:10

I'm going to go out on a limb, and guess that you are trying to implement the following:

The code should be self-explanatory, but the main idea is that you need to initialize a ScreenManager object in your main game class in order to be able to use the system. Take a look at the code below, and make sure you have something similar set up.

 ScreenManager screenManager;
 protected override void LoadContent()
       screenManager = new ScreenManager(this);
       screenManager.AddScreen(new BackgroundScreen(), null);
       screenManager.AddScreen(new MainMenuScreen(), null);
share|improve this answer
This, except for one detail - you shouldn't call Initialize manually because the Game class already calls Initialize for you when you add a Component during the game execution. You'd be initializing the ScreenManager twice this way. – David Gouveia Dec 13 '11 at 15:12
One also need to have the classes BackgroundScreen and MainMenuScreen implemented before writing this code -- just in case if somebody thinks that those are standard ones... – Alexander Galkin Dec 13 '11 at 19:06
By the way, I might add that this doesn't need to happen inside LoadContent, since the ScreenManager does not rely on the GraphicsDevice being initialized. Therefore you could safely move this code up into the Game's constructor (which is how it's done on the sample). – David Gouveia Dec 14 '11 at 0:38

Your Answer


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.