[SOLVED] Texture loading during splash screen display

How about loading from Update with a game state and not from LoadContent methods ^_^y

        GameState _GameState        = GameState.SplashScreen;
        int       _LoadingPercent   = 1;
        string    _LoadingLabel     = "";

        /// <summary>
        /// MAIN UPDATE
        /// </summary>       
        protected override void Update(GameTime gameTime)
        {

            switch (_GameState)
            {

                case GameState.SplashScreen:
                    {
                        if ( LoadingRoutine() == 1) _GameState = GameState.MainMenu;
                        break;
                    }

                case GameState.MainMenu:
                    {
                        int mOptionResult = MainMenuRoutine();
                        //
                        if (mOptionResult == 1) _GameState = GameState.Playing;
                        if (mOptionResult == 2) _GameState = GameState.Option;
                        if (mOptionResult == 3) _GameState = GameState.Exit;
                        //
                        break;
                    }

                case GameState.Option:
                    {
                        if (OptionRoutine() == 1) _GameState = GameState.MainMenu;
                        break;
                    }

                case GameState.Playing:
                    {
                        if (PlayingRoutine() == 1) _GameState = GameState.MainMenu;
                        break;
                    }

                case GameState.Exit:
                    {
                        QuitRoutine(); break;
                    }
            }
            

            base.Update(gameTime);
        }

      
        /// <summary>
        /// Loading routine
        /// </summary>
        /// <returns></returns>
        private int LoadingRoutine()
        {

            if (_LoadingPercent == 1)
            {
                // Load some of your content here      

                _LoadingLabel   = "Loading 10%";
                _LoadingPercent = 10;
                return 0;
            }
            else if (_LoadingPercent == 10)
            {
                // Load some of your content here

                _LoadingLabel   = "Loading 20%";
                _LoadingPercent = 20;
                return 0;                
            }
            else if (_LoadingPercent == 20)
            {
                // Load some of your content here

                _LoadingLabel   = "Loading 30%";
                _LoadingPercent = 30;
                return 0;
            }
            else if (_LoadingPercent == 30)
            {
                // Load some of your content here
                
                _LoadingLabel   = "Loading 40%";
                _LoadingPercent = 40;
                return 0;
            }
            else if (_LoadingPercent == 40)
            {
                // Load some of your content here

                _LoadingLabel   = "Loading 50%";
                _LoadingPercent = 50;
                return 0;
            }
            else if (_LoadingPercent == 50)
            {
                // Load some of your content here

                _LoadingLabel   = "Loading 60%";
                _LoadingPercent = 60;
                return 0;
            }
            else if (_LoadingPercent == 60)
            {
                // Load some of your content here

                _LoadingLabel   = "Loading 70%";
                _LoadingPercent = 70;
                return 0;
            }
            else if (_LoadingPercent == 70)
            {
                // Load some of your content here

                _LoadingLabel   = "Loading 80%";
                _LoadingPercent = 80;
                return 0;
            }
            else if (_LoadingPercent == 80)
            {
                // Load some of your content here

                _LoadingLabel   = "Loading 90%";
                _LoadingPercent = 90;
                return 0;
            }
            else if (_LoadingPercent == 90)
            {
                // Load some of your content here

                _LoadingLabel   = "Loading 100%";
                _LoadingPercent = 100;
                return 0;
            }
            else if (_LoadingPercent == 100)
            {

                // Load some of your content here

            }

            return 1; // Done loading all assets from here
        }

You can just divide your total contents by 10, If you have 50 contents load 5 contents every 10% you can play with the percent on how you want it to display by 5% with 20 calls on the loading routine and divide all your contents by 5.

1 Like