mainMenuState.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. function MainMenuState() {
  2. MainMenuState.superclass.constructor.apply(this);
  3. this.menuLayer = null;
  4. this.creditsLayer = null;
  5. this.bSound = null;
  6. this.bBack = null;
  7. this.a10Logo = null;
  8. this.moreGames = null;
  9. }
  10. extend(MainMenuState, TrinState);
  11. MainMenuState.prototype.update = function() {
  12. MainMenuState.superclass.update.apply(this);
  13. };
  14. MainMenuState.prototype.create = function() {
  15. MainMenuState.superclass.create.apply(this);
  16. this.menuLayer = new TrinLayer();
  17. var back = new TrinSprite();
  18. back.addAnimationFromCache("MainMenuBack");
  19. var bPlay = new TrinButton(function() {
  20. _TrinGame.switchState(new ComicsState());
  21. }, "bPlay", false);
  22. bPlay.orign.x = bPlay.width / 2;
  23. bPlay.reset(260, 490);
  24. this.bSound = new SoundButton();
  25. this.bSound.reset(520, 200);
  26. var creditsFunction = function(){
  27. var state = arguments.callee.state;
  28. state.menuLayer.active = state.menuLayer.visible = false;
  29. state.creditsLayer.active = state.creditsLayer.visible = true;
  30. state.moreGames.active =false;
  31. };
  32. creditsFunction.state = this;
  33. var bCredits = new TrinButton(creditsFunction, "bCredits", false);
  34. bCredits.reset(80, 200);
  35. var bMoreGames = new TrinButton(function(){
  36. //_TrinGame.SPIL_MOREGAMES.action();
  37. // Play68.goHome();
  38. }, "bMoreGames", true);
  39. bMoreGames.orign.x = bMoreGames.width;
  40. bMoreGames.reset(632, _TrinGame.visibleArea.top + 8);
  41. this.moreGames = bMoreGames;
  42. this.menuLayer.add(back);
  43. this.menuLayer.add(bPlay);
  44. this.menuLayer.add(this.bSound);
  45. this.menuLayer.add(bCredits);
  46. this.menuLayer.add(bMoreGames);
  47. this.creditsLayer = new TrinLayer();
  48. this.creditsLayer.visible = this.creditsLayer.active = false;
  49. back = new TrinSprite();
  50. back.addAnimationFromCache("CompleteBack");
  51. var credits = new TrinSprite();
  52. credits.addAnimationFromCache("CreditsInfo");
  53. var returnFunction = function(){
  54. var state = arguments.callee.state;
  55. state.menuLayer.active = state.menuLayer.visible = true;
  56. state.creditsLayer.active = state.creditsLayer.visible = false;
  57. state.moreGames.active =true;
  58. };
  59. returnFunction.state = this;
  60. var bReturn = new TrinButton(returnFunction, "bBack", false);
  61. bReturn.orign.x = bReturn.width / 2;
  62. bReturn.orign.y = bReturn.height;
  63. bReturn.reset(632 - bReturn.width / 2, _TrinGame.visibleArea.bottom - 8);
  64. this.bBack = bReturn;
  65. var a10Logo = new TrinButton(function(){
  66. //alert(123);
  67. //_TrinGame.SPIL_LOGO.action();
  68. }, "A10Logo", true);
  69. a10Logo.orign.y = a10Logo.height;
  70. a10Logo.reset(8, _TrinGame.visibleArea.bottom - 8);
  71. this.a10Logo = a10Logo;
  72. this.creditsLayer.add(back);
  73. this.creditsLayer.add(credits);
  74. this.creditsLayer.add(bReturn);
  75. this.add(this.menuLayer);
  76. this.add(this.creditsLayer);
  77. this.add(a10Logo);
  78. };
  79. MainMenuState.prototype.draw = function(context) {
  80. MainMenuState.superclass.draw.apply(this, [context]);
  81. };
  82. MainMenuState.prototype.resized = function(){
  83. this.bBack.y = _TrinGame.visibleArea.bottom - 8;
  84. this.a10Logo.y = _TrinGame.visibleArea.bottom - 8;
  85. this.moreGames.y = _TrinGame.visibleArea.top + 8;
  86. };