Пример #1
0
 void startThread() {
   if (gameThread != null) {
     if (gameThread.isRunning()) {
       return;
     }
   }
   gameThread = new GameThread(this, gameView);
   gameThread.start();
   Log.d("GameThread", "Thread started");
 }
Пример #2
0
  /**
   * <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);
  }
Пример #3
0
 /** Pause the game (stop the gamethread) */
 public void pause() {
   if (gameThread != null) {
     gameThread.stopRunning();
   }
 }
Пример #4
0
 /** End the game and close the application. */
 protected final void endGame() {
   gameThread.stopRunning();
   finish();
 }