Problem with reinnitializing my game

Last post 05-07-2008, 9:50 AM by Jim Perry. 1 replies.
Sort Posts: Previous Next
  •  05-05-2008, 6:24 PM

    Problem with reinnitializing my game

    I'm having a problem that happens randomly: when my game finishes and restarts, there's about a 1/10 chance that my objects do not redraw, but the game itself still works (I can still hear sound effects etc, and if I finish the game with the graphics not working and it restarts again, the graphics will come back).  Is this a graphics card issue possibly (I haven't had a chance to test it on another computer)?

    Here's the code in the game class, I can post the other classes if necessary, they work like you would expect:
            protected override void Initialize()
    {
    // Initialize sprite objects
    arrow = new Manager();
    background = new Background();
    base.Initialize();
    }

    protected override void LoadContent()
    {
    spriteBatch = new SpriteBatch(GraphicsDevice);
    arrow.LoadContent(this.Content, "Arrow", this.graphics);
    background.LoadContent(this.Content, "Table");
    }

    protected override void Update(GameTime gameTime)
    {
    if (arrow.resetgame == true)
    {
    Initialize();
    arrow.resetgame = false;
    }

    arrow.Update(gameTime);
    base.Update(gameTime);
    }


    Thanks for any help.
  •  05-07-2008, 9:50 AM

    Re: Problem with reinnitializing my game

    You really shouldn't be calling the Initialize method to start up a new game. I'd recommend moving the necessary code into something like an InitializeGame method and calling that from both the Initialize and wherever else you need to call it from.
    Jim Perry
    Here's what I'm up to.
View as RSS news feed in XML
©2007 Microsoft Corporation. All rights reserved. Privacy Statement Terms of Use Code of Conduct Feedback