Example #1
0
 private ScreenManager()
 {
     Dimesions = new Vector2(640, 480);
     currentScreen = new SplashScreen();
     xmlGameScreenManager.ThisType = currentScreen.ThisType;
     currentScreen = xmlGameScreenManager.Load("Load/SplashScreen.xml");
 }
        /// <summary>
        /// The constructor is private: loading screens should
        /// be activated via the static Load method instead.
        /// </summary>
        private LoadingScreen(ScreenManager screenManager, bool loadingIsSlow,
            GameScreen[] screensToLoad)
        {
            this.loadingIsSlow = loadingIsSlow;
            this.screensToLoad = screensToLoad;

            TransitionOnTime = TimeSpan.FromSeconds(0.5);
        }
Example #3
0
 public void ChangeScreens(string screenName)
 {
     newScreen = (GameScreen)Activator.CreateInstance(Type.GetType("SimpleGame." + screenName));
     image.IsActive = true;
     image.fadeEffect.Increase = true;
     image.Alpha = 0.0f;
     IsTransitioning = true;
 }
Example #4
0
 void Transition(GameTime gameTime)
 {
     if (IsTransitioning)
     {
         image.Update(gameTime);
         if (image.Alpha == 1.0f)
         {
             currentScreen.UnloadContent();
             currentScreen = newScreen;
             xmlGameScreenManager.ThisType = currentScreen.ThisType;
             if (File.Exists(currentScreen.XmlPath))
             {
                 currentScreen = xmlGameScreenManager.Load(currentScreen.XmlPath);
             }
             currentScreen.LoadContent();
         }
         else if (image.Alpha == 0.0f)
         {
             image.IsActive = false;
             IsTransitioning = false;
         }
     }
 }
        /// <summary>
        /// Adds a new screen to the screen manager.
        /// </summary>
        public void AddScreen(GameScreen screen, PlayerIndex? controllingPlayer)
        {
            screen.ControllingPlayer = controllingPlayer;
            screen.ScreenManager = this;
            screen.IsExiting = false;

            // If we have a graphics device, tell the screen to load content.
            if (isInitialized) {
                screen.LoadContent();
            }

            screens.Add(screen);
        }
        /// <summary>
        /// Removes a screen from the screen manager. You should normally
        /// use GameScreen.ExitScreen instead of calling this directly, so
        /// the screen can gradually transition off rather than just being
        /// instantly removed.
        /// </summary>
        public void RemoveScreen(GameScreen screen)
        {
            // If we have a graphics device, tell the screen to unload content.
            if (isInitialized) {
                screen.UnloadContent();
            }

            screens.Remove(screen);
            screensToUpdate.Remove(screen);
        }