Menu.java 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. package com.darkdimension.ritle_run;
  2. import android.graphics.Canvas;
  3. import android.graphics.Paint;
  4. public abstract class Menu
  5. {
  6. public static enum Action
  7. {
  8. TO_MAIN_MENU,
  9. TO_GAME,
  10. TO_EXTRA,
  11. EXIT_GAME,
  12. TO_FACEBOOK,
  13. TO_TWITTER,
  14. TO_TUMBLR,
  15. TO_PLAY_STORE,
  16. SHOW_AD,
  17. CHANGE_CHAR,
  18. NO_ACTION
  19. }
  20. //Create-Destroy
  21. protected DiAnimation aBasic = new DiAnimation(10);
  22. protected Paint invisible = new Paint();
  23. protected Action nMenu = null;
  24. //Touch
  25. protected boolean bTouched = false;
  26. protected int touchX = -1, touchY = -1;
  27. //Draw
  28. protected boolean bDraw = true;
  29. public Menu()
  30. {
  31. //Starting invisible
  32. invisible.setAlpha(0);
  33. //Starting Menu
  34. aBasic.startFromBeginning();
  35. }
  36. //Input
  37. protected boolean touch(int x, int y)
  38. {
  39. //Apply touch
  40. bTouched = true;
  41. touchX = x;
  42. touchY = y;
  43. //No sliding
  44. return false;
  45. }
  46. //Update
  47. protected Action update()
  48. {
  49. //Animation
  50. if (aBasic.update())
  51. {
  52. //Invisible animations
  53. invisible.setAlpha(aBasic.getCounter() * 255 / aBasic.getMax());
  54. //Draw Changes
  55. bDraw = true;
  56. }
  57. //Nothing happened
  58. return Action.NO_ACTION;
  59. }
  60. //Draw
  61. protected void draw(Canvas canvas)
  62. {
  63. //Don't draw again
  64. bDraw = false;
  65. }
  66. //Actions
  67. protected void forceDraw() {bDraw = true;}
  68. public void destroy(Action gMenu)
  69. {
  70. //Save next menu
  71. nMenu = gMenu;
  72. //Start destroy animation
  73. aBasic.startFromEnd();
  74. }
  75. //Isers
  76. public boolean isAnimating() {return aBasic.isRunning();}
  77. public boolean needsToBeDrawn(){return bDraw;}
  78. }