Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void salir() {
- paintThread.setRunning(false);
- Intent intent = new Intent(padre,Puntuacion.class);
- padre.startActivity(intent);
- padre.finish();
- }
- #padre es el activity donde estoy
- #puntuacion el activity al que voy
- #la funcion setRunning es para que pare el loop que lleva el thread, aqui te pongo la clase de ese thread para que lo
- #entiendas
- /////////////////////////////////////////////////////////
- public class GameThread extends Thread {
- private SurfaceHolder sh;
- private Vista view;
- private boolean run;
- public GameThread(SurfaceHolder sh, Vista view) {
- this.sh = sh;
- this.view = view;
- run = false;
- }
- public void setRunning(boolean run) {
- this.run = run;
- }
- public void run() {
- Canvas canvas;
- while(run) {
- canvas = null;
- try {
- canvas = sh.lockCanvas(null);
- synchronized(sh) {
- view.onDraw(canvas);
- }
- } finally {
- if(canvas != null)
- sh.unlockCanvasAndPost(canvas);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement