Exit In XNA
-
I have an input class in my XNA game, and I call a method from that class to the main class, to exit the game. (Basically)
class Game1 : XNA.blah,blah,blah { Input input; //etc void Initialize() { input = new Input(); } void Update(GameTime gameTime) { input.CheckInput(); } } public class Input : Game1 { public void CheckInput() { if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { this.Exit(); //or should it be Game1.Exit()? but that doesn't exit } } }
*there's more code, but that's not the issue; regualr stuff it starts with So, how would I make the game exit from a different class? Thanks.- I love D-flat!
-
I have an input class in my XNA game, and I call a method from that class to the main class, to exit the game. (Basically)
class Game1 : XNA.blah,blah,blah { Input input; //etc void Initialize() { input = new Input(); } void Update(GameTime gameTime) { input.CheckInput(); } } public class Input : Game1 { public void CheckInput() { if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { this.Exit(); //or should it be Game1.Exit()? but that doesn't exit } } }
*there's more code, but that's not the issue; regualr stuff it starts with So, how would I make the game exit from a different class? Thanks.- I love D-flat!
public class Game1{
private Input mInput;public Game1(){ mInput = new Input(this); }
}
public class Input{
private Game1 mGame;public void CheckInput(){ mGame.Exit(); } public Input(Game1 game){ mGame = game; }
}
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway