Hi everyone.
I'm fairly new to coding and have had very little tuition to get to where I am, but I am very stuck with this problem on my latest University assignment.
First of all, I was given the framework to start working with from the University and as such, the project type is a Class Library, but it runs as a game. The game itself is a simple side-scrolling shooter similar to the classic R-Type game series. The project itself doesn't have to display that many techniques, so it's only a 2D game using mostly graphics I've been given.
As a way to show extra credit, I'm trying to implement a series of menu screens using Windows Forms. I have one that is created when the application is launched to be the opening menu. It has 2 buttons. One which launches the game (by closing the form and playing the scene using a this.PlayScene(Scene) method. The second button is supposed to exit the game, but I don't know how to get this one to work.
So far, I have tried methods such as:
public void button2_Click(object sender, EventArgs e)
{
this.Close();
mKernel.Exit();
}
In Form1:
int _counter = 0;
public int setCounter(int counter)
{
counter = _counter;
return counter;
}
public void button2_Click(object sender, EventArgs e)
{
_counter++;
this.Close();
}
In Kernel:
int counter = 0;
form1.ShowDialog();
form1.Focus();
counter = form1.setCounter(counter);
if (counter != 0)
{
this.Exit();
}
In both cases, the Kernel class is the main XNAGame class. In every attempt I've tried, clicking the button simply closes the form and runs the scene as normal. Is there any way I could possibly get the Kernel class to exit the game after the form is closed and this button was clicked in order to close it?