Sign in to follow this  
theStormWeaver

Graphics Device that just won't die

Recommended Posts

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this