Example #1
0
  /*
   * Callback invoked when the Surface has been created and is ready to be
   * used.
   */
  public void surfaceCreated(SurfaceHolder holder) {
    // start the thread here so that we don't busy-wait in run()
    // waiting for the surface to be created

    if (thread.getState() == Thread.State.TERMINATED) {
      thread = new GameThread(holder, getContext(), new Handler());
      thread.setRunning(true);
      thread.start();
      thread.doStart();
      startLevel();
    } else {
      thread.setRunning(true);
      thread.start();
    }
  }
Example #2
0
 public void killThread() {
   boolean retry = true;
   gthread.setRunning(false);
   while (retry) {
     try {
       gthread.join();
       retry = false;
     } catch (InterruptedException e) {
     }
   }
 }
Example #3
0
 /*
  * Callback invoked when the Surface has been destroyed.
  */
 public void surfaceDestroyed(SurfaceHolder holder) {
   boolean retry = true;
   thread.setRunning(false);
   while (retry) {
     try {
       thread.join();
       retry = false;
     } catch (InterruptedException e) {
       Log.e("Tile Game Example", e.getMessage());
     }
   }
 }
Example #4
0
 public void surfaceDestroyed(SurfaceHolder holder) {
   if (thread != null) {
     boolean retry = true;
     thread.setRunning(false);
     while (retry) {
       try {
         thread.join();
         retry = false;
       } catch (InterruptedException e) {
       }
     }
   }
   thread = null;
 }
Example #5
0
 public void onPause() {
   super.onPause();
   gameThread.setRunning(false);
 }