src/state/state.js
function _switchState(state) {
            // clear previous interval if any
            _stopRunLoop();

            // call the stage destroy method
            if (_stages[_state]) {
                // just notify the object
                _stages[_state].stage.destroy();
            }

            if (_stages[state]) {
                // set the global variable
                _state = state;

                // call the reset function with _extraArgs as arguments
                _stages[_state].stage.reset.apply(_stages[_state].stage, _extraArgs);

                // and start the main loop of the
                // new requested state
                _startRunLoop();

                // execute callback if defined
                if (_onSwitchComplete) {
                    _onSwitchComplete();
                }

                // force repaint
                me.game.repaint();
            }
        }
function _switchState(state) {
            // clear previous interval if any
            _stopRunLoop();

            // call the stage destroy method
            if (_stages[_state]) {
                // just notify the object
                _stages[_state].stage.destroy();
            }

            if (_stages[state]) {
                // set the global variable
                _state = state;

                // call the reset function with _extraArgs as arguments
                _stages[_state].stage.reset.apply(_stages[_state].stage, _extraArgs);

                // and start the main loop of the
                // new requested state
                _startRunLoop();

                // execute callback if defined
                if (_onSwitchComplete) {
                    _onSwitchComplete();
                }

                // force repaint
                me.game.repaint();
            }
        }
function _switchState ( state ) { // clear previous interval if any _stopRunLoop ( ) ; // call the stage destroy method if ( _stages [ _state ] ) { // just notify the object _stages [ _state ] . stage . destroy ( ) ; } if ( _stages [ state ] ) { // set the global variable _state = state ; // call the reset function with _extraArgs as arguments _stages [ _state ] . stage . reset . apply ( _stages [ _state ] . stage , _extraArgs ) ; // and start the main loop of the // new requested state _startRunLoop ( ) ; // execute callback if defined if ( _onSwitchComplete ) { _onSwitchComplete ( ) ; } // force repaint me . game . repaint ( ) ; } }
start the SO main loop
@ignore
start the SO main loop