1

Is it possible to run a XNA game after exiting another?
I tried to write at the default XNA's "Program.cs":

using (Game1 game = new Game1())
{
    game.Run();
}

using (Game2 game = new Game2())
{
    game.Run();
}

but after exiting the first game the second was running once and then just exited the game....

edit:
I found that when I try to exit the window with the X button (of the window...) the second game window starts...

csharpwinphonexaml
  • 3,659
  • 10
  • 32
  • 63

2 Answers2

0

You might want to use the OnExiting() method in your Game1 class to create a new instance of a game when one is closed.

protected override void OnExiting(Object sender, EventArgs args)
{
    using (Game2 game = new Game2())
    {
        game.Run();
    }
    base.OnExiting(sender, args);
}
Cyral
  • 13,999
  • 6
  • 50
  • 90
0

Chances are, you can accomplish what you are trying to do, by using Game Components instead.

I'm not entirely sure what you are trying to do here, but more than likely there is a better solution.

More information on game components here.

Community
  • 1
  • 1
jgallant
  • 11,143
  • 1
  • 38
  • 72