/* * 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(); } }
public void killThread() { boolean retry = true; gthread.setRunning(false); while (retry) { try { gthread.join(); retry = false; } catch (InterruptedException e) { } } }
/* * 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()); } } }
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; }
public void onPause() { super.onPause(); gameThread.setRunning(false); }