コード例 #1
0
        /// <summary>
        /// If there is a state change requested during the update loop,
        /// this function handles actual destroying the old state and related processes,
        /// and calls creates on the new state and plugs it into the game object.
        /// </summary>
        protected void switchState()
        {
            FlxG.resetCameras();
            FlxG.resetInput();
            FlxG.destroySounds();
            //FlxG.clearBitmapCache();

            // Clear the debugger overlay's Watch window
            //if(_debugger != null)
            //    _debugger.watch.removeAll();

            // Clear any timers left in the timer manager
            //var timerManager:TimerManager = FlxTimer.manager;
            //if(timerManager != null)
            //    timerManager.clear();

            // Destroy the old state (if there is an old state)
            if (State != null)
            {
                State.destroy();
            }

            // Finally assign and create the new state
            State = RequestedState;
            State.create();
        }