Ejemplo n.º 1
0
        public void Update(GameTime gameTime)
        {
            // TODO: Find a better way to handle this
            latestInputReceiver = FindInputReceiver();
            if (latestInputReceiver != null)
                latestInputReceiver.HandleInput (gameTime);

            foreach (var state in states)
                state.Update (gameTime);

            if (currentTransition != null)
                UpdateTransition(gameTime);

            //  Pop all marked states, you can't do this during Update()
            if (markToPopCount > 0)
            {
                for (int i=0; i < markToPopCount; i++)
                    PopState();

                markToPopCount = 0;
            }

            // Set state
            if (nextState != null)
            {
                foreach (var state in states)
                    state.OnLostFocus ();

                states.Clear ();
                states.Add (nextState);
                nextState.OnFocus ();

                nextState = null;
            }

            // Push all new states on to the stack outside of Update()
            while (markToPush.Count > 0)
            {
                states.Add (markToPush.Dequeue ());
                CurrentState.OnFocus();
            }
        }