Esempio n. 1
0
  @Override
  public void surfaceCreated(SurfaceHolder holder) {
    if (thread.getState() == Thread.State.TERMINATED) {
      thread = new GameLoopThread();
    }

    // start the game loop
    thread.setIsRunning(true);
    thread.start();
  }
  // SurfaceHolder.Callback methods:
  @Override
  public void surfaceCreated(SurfaceHolder surfaceHolder) {
    // thread exists, but is in terminated state
    if (thread.getState() == Thread.State.TERMINATED) {
      thread = new GameLoopThread();
    }

    // start the game loop
    thread.setIsRunning(true);
    thread.start();
  }
Esempio n. 3
0
  @Override
  public void surfaceDestroyed(SurfaceHolder holder) {
    boolean retry = true;
    thread.setIsRunning(false);

    while (retry) {
      try {
        thread.join();
        retry = false;
      } catch (InterruptedException e) {
      }
    }
  }
Esempio n. 4
0
 @Override
 public boolean onTouchEvent(MotionEvent event) {
   if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
     thread.screenTouched();
   }
   return true;
 }