void startThread() { if (gameThread != null) { if (gameThread.isRunning()) { return; } } gameThread = new GameThread(this, gameView); gameThread.start(); Log.d("GameThread", "Thread started"); }
/** * <b>DO NOT CALL THIS METHOD</b> * * <p>This method is part of the Android Activity lifecycle which is managed by GameEngine itself. */ @Override protected final void onResume() { super.onResume(); printDebugInfo("GameEngine", "onResume()..."); // Note: only restart thread after a real pause, not at startup if (gameThread != null) { if (gameThread.getState() == Thread.State.TERMINATED) { startThread(); } } GameSound.resumeSounds(); MusicPlayer.resumeAll(); MotionSensor.handleOnResume(this); }
/** Pause the game (stop the gamethread) */ public void pause() { if (gameThread != null) { gameThread.stopRunning(); } }
/** End the game and close the application. */ protected final void endGame() { gameThread.stopRunning(); finish(); }