Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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 have two classes in my game, a Main Menu and the main playing screen. How can I swap through classes? E.g I click on "New Game" in the menu class and it changes it too the Game class. A transition animation explanation would be nice.

share|improve this question

You need some kind of gamestate-management system in place.

I could write a long answer explaining this, but people who are a lot more experienced with XNA and game programming than me have already done that, so I shall point you towards them.

Personally I've found this example to be excellent:

It shows a gamestate-management system with the ability to easily add as many gamestates as you like, as well as defining transitions in and out of the gamestate.

You should give it a read!

share|improve this answer

You probably want to look into state machines. Here's a popular App Hub tutorial on game state management, and here's another random Google result for XNA state machine information (it's not really a topic that needs to be specific to XNA, so you can get broader search results in Google if you exclude the "XNA" bit, if you want to research the topic more yourself).

Once you have the basic implementation of such a system, you can expand it by adding (for example) animations that play as you transition in or out of states.

share|improve this answer

Game State Management is what you're after. Once you have the states sorted out, when they transition you can create whatever effect you desire (fade out, in, black out, white out, etc) and that's what shaders are for. But that's probably a slightly separate question.

Another article that could be interesting is this which describes an actual application of it.

share|improve this answer

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.