lib/melonJS-0.9.4.js
/**
		 * start the SO main loop
		 * @ignore
		 */
start the SO main loop
@ignore
start the SO main loop @ignore
function _switchState(state) {
			_stopRunLoop();
			if (_screenObject[_state]) {
				if (_screenObject[_state].screen.visible)
					me.game.remove(_screenObject[_state].screen);
				else
					_screenObject[_state].screen.destroy();
			}
			if (_screenObject[state])
			{
				_state = state;
				_screenObject[_state].screen.reset.apply(_screenObject[_state].screen, _extraArgs);
				_activeUpdateFrame = _screenObject[_state].screen.onUpdateFrame.bind(_screenObject[_state].screen);
				_startRunLoop();
				if (_onSwitchComplete) {
					_onSwitchComplete();
				}
				me.game.repaint();
			 }
		}
function _switchState ( state ) { _stopRunLoop ( ) ; if ( _screenObject [ _state ] ) { if ( _screenObject [ _state ] . screen . visible ) me . game . remove ( _screenObject [ _state ] . screen ) ; else _screenObject [ _state ] . screen . destroy ( ) ; } if ( _screenObject [ state ] ) { _state = state ; _screenObject [ _state ] . screen . reset . apply ( _screenObject [ _state ] . screen , _extraArgs ) ; _activeUpdateFrame = _screenObject [ _state ] . screen . onUpdateFrame . bind ( _screenObject [ _state ] . screen ) ; _startRunLoop ( ) ; if ( _onSwitchComplete ) { _onSwitchComplete ( ) ; } me . game . repaint ( ) ; } }
start the SO main loop
 @ignore
start the SO main loop @ignore
// clear previous interval if any // call the screen object destroy method // set the global variable // call the reset function with _extraArgs as arguments // cache the new screen object update function // and start the main loop of the  // new requested state // execute callback if defined // force repaint