Graphics Device that just won't die

Started by
0 comments, last by theStormWeaver 17 years, 1 month ago
I'm using C# and DirectX 9.0c Here's whats happening: I use a standard windows form as an opening menu where you can choose which level to play and what your background music is. When you win/lose the game window closes and the frmMain regains focus. The second time the game is run and closes it produces an error, a null reference exception to the graphics device at the beginning of the scene rendering. My EndGame method (which is called when the player runs out of lives or wins the game) looks like this:

private void EndGame(string message)
        {
            try
            {
                BreakOut.frmMain.theMenuScreen.setLabel(message);
                bgSound.Stop();
                this.Hide();
                BreakOut.frmMain.theMenuScreen.Show();
                BreakOut.frmMain.theMenuScreen.Focus();
                graphicsDevice.Dispose();
            }//end try

            catch(Exception e)
            {
                messageboxOK(e.Message);
            }//end catch
        }//end EndGame

Advertisement
bump

This topic is closed to new replies.

Advertisement