the error

I would like my game to come up to the opening scene, and when i press the spacebar it goes away and my game starts.

I have tried something like this in my program:

void _startGame;

{
using (Blank game = new Blank())
{
game.Run();
}
}

But when i press spacebar it gives me an error.
Thanks, for the help!



Answer this question

the error

  • Abdollah

    Are you trying to make a loading window which then goes to fullscreen I'd recommend just having it go to fullscreen right away. No reason to over complicate things :)


  • JRQ

    DragonC# wrote:
    It's ok, i found something that if i make the Vector2 a negative and tell the splash to move up from its starting position to a point on the screen where it's not visible it wont show anymore

    This is a hack and I would suggest fixing it properly, otherwise it'll probably cause more problems down the road than it fixes.



  • orent

    Everything seems to work, but when i hit space it always throws an error (only when i try to run the game inside the already existing loop), how can i make a screen that shows up and when spacebar is hit it will close and the actual game will begin. So if i hit space this screen disappears and then my actual game appears and i can start playing it.

    Thx for the feedback and i hope i can get a useful reply out of all of them.


  • moose151

    Ok, so i understand i cant run another game in the same window, so how do i make it to where the splash screen appears and when spacebar is pressed it goes away and there the game is. Or maybe even a button that would make the splash screen disappear.

    If you can plz right the code and thx again for all the Help


  • TwilightBrigade

    Please, for the love of the techno gods, tell us what the error is so we can help you.


  • tjorvi

    It's ok,  i found something that if i make the Vector2 a negative and tell the splash to move up from its starting position to a point on the screen where it's not visible it wont show anymore

    Thx for all your help!


  • David N.4117

    Sadly this forum isn't a place for people to just write lots of code for other people to use. However, check out the SpaceWar sample. It has a splash screen that appears and when you press A or B on the controller it plays the game.



  • j2associates

    Why not jsut set a flag when you hit space

    bool showSplash = true;

    in Upate()

    if (keyDown(Space)) showSplash=false

    in Draw()

    if (showSpash)

    {

    do the spash screen rendering

    }

    else

    {

    do the game screen rendering

    }



  • Scott Allison

    Thanks for the info regarding GameComponents. I know someone's blog has mentioned this before, but I have not yet spent the time to fully digest it all.

  • Juice Johnson

    Do the sample apps work fine Did you start from the XNA Game template

  • Misiacik7

    You might want to look into using GameComponents or a similar OO method of handling what's displayed. For a small game you can get away with doing things like that, but the more you add to it the more difficult it's going to be to maintain. I believe there's some tutorials on doing this on the various XNA tutorial sites.

  • Sobia

    I see what you are trying to do now. When you hit space you are starting up another game object - which you can't do.

    Right now if you are using the Game objects you can use just the one window. If you want to do more you will have to not use Game and go much more low level and handle all the device stuff and window creation yourself. I don't think there are many (any ) examples of how to do that with XNA at the moment and you will have big problems ever running that on an xbox (no windows on there just the one that XNA creates for you).

    You can just show different screens within that window like in SpaceWars - is that enough.



  • Luke R

    InvalidOperationException, Starting a second loop on a single thread is not a valid operation.
  • Kyle J.

    I did exactly what you are requesting by doing something very similar to what The ZMan stated. I actually maintain a current step, and name my steps something like CURRENT_STEP_SPLASH, CURRENT_STEP_LEVEL1_PLAY, CURRENT_STEP_LEVEL2_SPLASH, etc. Each step is a 'const int' and marked numerically in sequence.

    After certain events, a mouse click to remove the SPLASH screen, for example, the currentStep counter is increased by one, moving the code to run the next step. I also increase the current step at the end of each playable level. Below is an example of some of my code.

    private const int STEP_TITLE_PAGE = 0;
    private const int STEP_OPENING_PAGE = 1;
    private const int STEP_INTRO_LEVEL_1 = 2;
    private const int STEP_PLAY_LEVEL_1 = 3;
    private const int STEP_INTRO_LEVEL_2 = 4;
    private const int STEP_PLAY_LEVEL_2 = 5;
    private int m_CurrentStep = STEP_TITLE_PAGE;

    In the Draw() method, I check the current step to figure out what to draw.

    if (m_CurrentStep == STEP_TITLE_PAGE)
    {
    spriteBatch.Draw(t2dTitlePage,
    new Rectangle(0, 0, 800, 600), Color.White);
    }
    else if (m_CurrentStep == STEP_OPENING_PAGE)
    {
    spriteBatch.Draw(t2dOpeningPage,
    new Rectangle(0, 0, 800, 600), Color.White);
    }
    ........and so on.


  • the error