14.06.2011

startGame()

posted by Karsten

private void startGame(GameView gView, GameThread gThread, Bundle savedInstanceState) { if (savedInstanceState == null) { // we were just launched: set up a new game mGameThread = new GameThread(mGameView); mGameView.setThread(mGameThread); mGameThread.setState(GameThread.STATE_READY); } else { if(mGameThread != null) { //Thread is lives, just restart it! mGameThread.restoreState(savedInstanceState); if(mGameThread.getMode() == GameThread.STATE_RUNNING) { mGameThread.setState(GameThread.STATE_PAUSE); } } else { //make a new thread with the values from savedInstanceState gThread = new GameThread(mGameView); mGameView.setThread(gThread); mGameThread = mGameView.getThread(); mGameThread.restoreState(savedInstanceState); mGameThread.setState(GameThread.STATE_READY); } } mGameView.startSensor((SensorManager)getSystemService(Context.SENSOR_SERVICE)); }

Share

Place your comment

Please fill your data and comment below.
Name
Email
Website
Your comment