XNA Creators Club Online
Page 1 of 1 (6 items)
Sort Posts: Previous Next

Adding a splashscreen with the GSM

Last post 06-16-2008 7:11 AM by ragnarrok. 5 replies.
  • 04-17-2008 2:31 AM

    Adding a splashscreen with the GSM

    I know its because im probably just overtired, but Ive been trying to add a new screen to the game state management, pause it for 3 seconds, then continue to load the background and main menu. My first thought was to create the screen (done) then add it to game.cs here

                // Activate the first screens.
                screenManager.AddScreen(new CdxLogoScreen());
                screenManager.AddScreen(new BackgroundScreen());
                screenManager.AddScreen(new MainMenuScreen(this));

    problem is, it instantly just pops the backgroundscreen on and mainmenuscreen on.. hence the splash doesnt show. Where would I add that in? the gsm is complex (to me) and im still learning and playing with it..
    Development site: CDX Games
  • 04-17-2008 8:02 AM In reply to

    Re: Adding a splashscreen with the GSM

    Answer

    The ScreenManager shows the screens in the order you add them with screens that are added later showing 'over' screens before.

    So, the background screen shows 'over' your title screen, and the main menu on top of that.

    To get the title screen to show first, add your 'Title Screen' after the Main Menu - it will then be displayed first.

    Here is my start sequence.

    screenManager.AddScreen(new BackgroundScreen());
    screenManager.AddScreen(new MainMenuScreen());

    screenManager.AddScreen(new VideoScreen("Video/Intro.wmv"));
    screenManager.AddScreen(new TitleScreen("wrath-logo"));
    screenManager.AddScreen(new TitleScreen("publisher-logo"));

    In this way, the publisher logo is shown first, then when it transitions off the company logo and when that transitions off, a video, followed by the main menu.

     

    --
    Ruina et Stragos
    XNA SA
    --
  • 04-17-2008 9:54 AM In reply to

    Re: Adding a splashscreen with the GSM

    Doh.. makes perfect sense... especially with the transition times and all.. I guess i was just more tired than I thought last night.. =) Thanks DrDeth!
    Development site: CDX Games
  • 06-15-2008 10:22 PM In reply to

    Re: Adding a splashscreen with the GSM

    Been playing around with various things trying to get an idea of how things work. I came upon this when I had the same idea (wanted to add a logo screen to the GSM) but I don't seem to get how these new screens transition into each other. I tried and the new screen just sits there and never moves to the MainMenuScreen. Just curious what the TitleScreen ends up looking like. And with this method, can you really embed a WMV file using this same method? Thanks for the help.
  • 06-16-2008 6:14 AM In reply to

    Re: Adding a splashscreen with the GSM

    Well, basically, my TitleScreen updates just like most of the other game screens by updating the transition. For my TitleScreen transition I use a simple fade by setting the TransitionAlpha. When the screen finishes transitioning on, I start recording the elapsed time in a TimeSpan variable. When this value is greater than my desired 'show time', I call ExitScreen, which causes the screen to transition off.

            public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)  
            {  
                this.otherScreenHasFocus = otherScreenHasFocus;  
     
                if (!otherScreenHasFocus && !coveredByOtherScreen)  
                {  
                    if (!IsExiting)  
                    {  
                        float transitionDelta = (float)(gameTime.ElapsedGameTime.TotalMilliseconds /  
                                          TransitionOnTime.TotalMilliseconds);  
     
                        // Update the transition position.  
                        TransitionPosition = MathHelper.Clamp(TransitionPosition - transitionDelta, 0, 1);  
     
                        // Record how long the title has been displayed.  
                        elapsedTime += gameTime.ElapsedGameTime;  
     
                        if (elapsedTime > displayTime + TransitionOnTime)  
                        {  
                            ExitScreen();  
                        }  
                    }  
                    else 
                    {  
                        if (!instantOff)  
                        {  
     
                            float transitionDelta = (float)(gameTime.ElapsedGameTime.TotalMilliseconds /  
                                              TransitionOffTime.TotalMilliseconds);  
     
                            // Update the transition position.  
                            TransitionPosition = MathHelper.Clamp(TransitionPosition + transitionDelta, 0, 1);  
                        }  
                        else 
                        {  
                            TransitionPosition = 1;  
                        }  
     
                        // Finished transitioning off  
                        if (TransitionPosition == 1)  
                        {  
                            ScreenManager.RemoveScreen(this);  
                        }  
                    }  
                }  
            }  
     

    Video is almost identical, except that I'm not waiting a specific amount of time, I'm waiting for the video to finish playing. I am using my own video class that wraps the functionality of DirectShowLib in a nice easy to use Video class - so, it works for Windows, but wont work on XBox.

     

    --
    Ruina et Stragos
    XNA SA
    --
  • 06-16-2008 7:11 AM In reply to

    Re: Adding a splashscreen with the GSM

    Yeah I had a feeling it wouldn't work on the xbox so I had to ask :) thank you for the clarification. & I got it to work now! Thanks so much for your help. All I need now is an idea for a game. Take care! :D

     

    thomas


Page 1 of 1 (6 items) Previous Next