コード例 #1
0
        // update for given elapsed time
        public void Update(float elapsedTime)
        {
            // if in a transition
            if (fade > 0)
            {
                // update transition time
                fade -= elapsedTime;

                // if time to switch to new screen (fade out finished)
                if (next != null && fade < 0.5f * fadeTime)
                {
                    // tell new screen it is getting in focus
                    next.SetFocus(contentManager, true);

                    // tell the old screen it lost its focus
                    if (current != null)
                        current.SetFocus(contentManager, false);

                    // set new screen as current
                    current = next;
                    next = null;
                }
            }

            // if current screen available, update it
            if (current != null)
                current.Update(elapsedTime);

            // calulate frame rate
            frameRateTime += elapsedTime;
            if (frameRateTime > 0.5f)
            {
                frameRate = (int)((float)frameRateCount / frameRateTime);
                frameRateCount = 0;
                frameRateTime = 0;
            }

            // accumulate elapsed time for background animation
            backgroundTime += elapsedTime;
        }
コード例 #2
0
 // starts a transition to a new screen
 // using a 1 sec fade time to custom color
 public bool SetNextScreen(ScreenType screenType, Vector4 fadeColor,
     float fadeTime)
 {
     // if no transition already happening
     if (next == null)
     {
         // set next screen and transition options
         next = screens[(int)screenType];
         this.fadeTime = fadeTime;
         this.fadeColor = fadeColor;
         this.fade = this.fadeTime;
         return true;
     }
     return false;
 }