Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. private void salir() {
  2. paintThread.setRunning(false);
  3. Intent intent = new Intent(padre,Puntuacion.class);
  4. padre.startActivity(intent);
  5. padre.finish();
  6. }
  7. #padre es el activity donde estoy
  8. #puntuacion el activity al que voy
  9. #la funcion setRunning es para que pare el loop que lleva el thread, aqui te pongo la clase de ese thread para que lo
  10. #entiendas
  11.  
  12. /////////////////////////////////////////////////////////
  13.  
  14. public class GameThread extends Thread {
  15.  
  16. private SurfaceHolder sh;
  17. private Vista view;
  18. private boolean run;
  19.  
  20. public GameThread(SurfaceHolder sh, Vista view) {
  21. this.sh = sh;
  22. this.view = view;
  23. run = false;
  24. }
  25.  
  26. public void setRunning(boolean run) {
  27. this.run = run;
  28. }
  29.  
  30.  
  31. public void run() {
  32. Canvas canvas;
  33. while(run) {
  34. canvas = null;
  35. try {
  36. canvas = sh.lockCanvas(null);
  37. synchronized(sh) {
  38. view.onDraw(canvas);
  39. }
  40. } finally {
  41. if(canvas != null)
  42. sh.unlockCanvasAndPost(canvas);
  43. }
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement