CHelpPanel.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. function CHelpPanel(iXPos, iYPos, oSprite) {
  2. var _oTitle;
  3. var _oText1;
  4. var _oHelpBg;
  5. var _oFade;
  6. var _oGroup;
  7. var _oButContinue;
  8. var _oContainerAnim;
  9. var _bClick = false;
  10. this._init = function (iXPos, iYPos, oSprite) {
  11. _oGroup = new createjs.Container();
  12. _oGroup.x = iXPos;
  13. _oGroup.y = iYPos;
  14. s_oStage.addChild(_oGroup);
  15. _oFade = new createjs.Shape();
  16. _oFade.graphics.beginFill("black").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
  17. _oFade.alpha = 0.5;
  18. _oGroup.addChild(_oFade);
  19. _oHelpBg = createBitmap(oSprite);
  20. _oHelpBg.x = CANVAS_WIDTH_HALF;
  21. _oHelpBg.y = CANVAS_HEIGHT_HALF;
  22. _oHelpBg.regX = oSprite.width * 0.5;
  23. _oHelpBg.regY = oSprite.height * 0.5;
  24. _oGroup.addChild(_oHelpBg);
  25. _oTitle = new createjs.Text(TEXT_HOW_TO_PLAY, "50px " + FONT2, "#ffffff");
  26. _oTitle.textAlign = "center";
  27. _oTitle.lineWidth = 500;
  28. _oTitle.x = CANVAS_WIDTH * 0.5;
  29. _oTitle.y = CANVAS_HEIGHT * 0.5 - 240;
  30. _oGroup.addChild(_oTitle);
  31. var szText;
  32. if (s_bMobile) {
  33. szText = TEXT_HELP1_MOBILE_BATTER;
  34. } else {
  35. szText = TEXT_HELP1_PC_BATTER;
  36. }
  37. _oText1 = new createjs.Text(szText, "28px " + FONT2, "#ffffff");
  38. _oText1.textAlign = "center";
  39. _oText1.lineWidth = 450;
  40. _oText1.x = CANVAS_WIDTH * 0.5;
  41. _oText1.y = CANVAS_HEIGHT * 0.5 - 170;
  42. _oGroup.addChild(_oText1);
  43. _oContainerAnim = new createjs.Container();
  44. var oSpriteTarget = s_oSpriteLibrary.getSprite("ball_target");
  45. var oTargetLeft = new CBallTarget(CANVAS_WIDTH_HALF - 150, CANVAS_HEIGHT_HALF - 30, oSpriteTarget, _oContainerAnim);
  46. var oTargetUp = new CBallTarget(CANVAS_WIDTH_HALF, CANVAS_HEIGHT_HALF - 30, oSpriteTarget, _oContainerAnim);
  47. var oTargetRight = new CBallTarget(CANVAS_WIDTH_HALF + 150, CANVAS_HEIGHT_HALF - 30, oSpriteTarget, _oContainerAnim);
  48. var oSpriteKeyLeft;
  49. var oSpriteKeyUp;
  50. var oSpriteKeyRight;
  51. if (!s_bMobile) {
  52. oSpriteKeyLeft = s_oSpriteLibrary.getSprite("key_left");
  53. oSpriteKeyUp = s_oSpriteLibrary.getSprite("key_up");
  54. oSpriteKeyRight = s_oSpriteLibrary.getSprite("key_right");
  55. } else {
  56. oSpriteKeyLeft = s_oSpriteLibrary.getSprite("arrow");
  57. oSpriteKeyUp = s_oSpriteLibrary.getSprite("arrow");
  58. oSpriteKeyRight = s_oSpriteLibrary.getSprite("arrow");
  59. }
  60. var oKeyLeft = this.createKey(CANVAS_WIDTH_HALF - 150, CANVAS_HEIGHT_HALF + 60, oSpriteKeyLeft);
  61. var oKeyUp = this.createKey(CANVAS_WIDTH_HALF, CANVAS_HEIGHT_HALF + 60, oSpriteKeyUp);
  62. var oKeyRight = this.createKey(CANVAS_WIDTH_HALF + 150, CANVAS_HEIGHT_HALF + 60, oSpriteKeyRight);
  63. var iScaleLeftDown = 0.8;
  64. if (s_bMobile) {
  65. oKeyLeft.scaleX = -1;
  66. iScaleLeftDown = -0.8;
  67. oKeyUp.rotation = 270;
  68. }
  69. _oContainerAnim.addChild(oKeyLeft, oKeyUp, oKeyRight);
  70. _oGroup.addChild(_oContainerAnim);
  71. var oParent = this;
  72. this.animKeyTarget(oKeyLeft, oTargetLeft, oKeyUp, oTargetUp, oKeyRight, oTargetRight, 250, 250, oKeyLeft.scaleX, iScaleLeftDown);
  73. var oSpriteContiune = s_oSpriteLibrary.getSprite('but_continue');
  74. _oButContinue = new CGfxButton(CANVAS_WIDTH / 2, CANVAS_HEIGHT_HALF + 180, oSpriteContiune, _oGroup);
  75. _oButContinue.addEventListener(ON_MOUSE_UP, this._onExitHelp, this);
  76. _oButContinue.pulseAnimation();
  77. _oGroup.on("pressup", function () {
  78. oParent._onExitHelp();
  79. });
  80. };
  81. this.animKeyTarget = function (oKeyLeft, oTargetLeft, oKeyUp, oTargetUp, oKeyRight, oTargetRight, iWaitTime, iTime, iScale, iScaleLeftDown) {
  82. var oParent = this;
  83. createjs.Tween.get(oKeyLeft).wait(iWaitTime).call(function () {
  84. oParent.changeAnimArrayTarget(oKeyLeft, oTargetLeft, iScaleLeftDown, 0.8, true);
  85. createjs.Tween.get(oKeyLeft).wait(iTime).call(function () {
  86. oParent.changeAnimArrayTarget(oKeyLeft, oTargetLeft, iScale, 1, false);
  87. createjs.Tween.get(oKeyUp).wait(iWaitTime).call(function () {
  88. oParent.changeAnimArrayTarget(oKeyUp, oTargetUp, 0.8, 0.8, true);
  89. createjs.Tween.get(oKeyUp).wait(iTime).call(function () {
  90. oParent.changeAnimArrayTarget(oKeyUp, oTargetUp, 1, 1, false);
  91. createjs.Tween.get(oKeyRight).wait(iWaitTime).call(function () {
  92. oParent.changeAnimArrayTarget(oKeyRight, oTargetRight, 0.8, 0.8, true);
  93. createjs.Tween.get(oKeyRight).wait(iTime).call(function () {
  94. oParent.changeAnimArrayTarget(oKeyRight, oTargetRight, 1, 1, false);
  95. oParent.animKeyTarget(oKeyLeft, oTargetLeft, oKeyUp, oTargetUp, oKeyRight, oTargetRight, iWaitTime, iTime, iScale, iScaleLeftDown);
  96. });
  97. });
  98. });
  99. });
  100. });
  101. });
  102. };
  103. this.changeAnimArrayTarget = function (oKey, oTarget, fScaleX, fScaleY, bState) {
  104. oKey.scaleX = fScaleX;
  105. oKey.scaleY = fScaleY;
  106. oTarget.changeState(bState);
  107. };
  108. this.createKey = function (iX, iY, oSprite) {
  109. var oKey;
  110. oKey = createBitmap(oSprite);
  111. oKey.x = iX;
  112. oKey.y = iY;
  113. oKey.regX = oSprite.width * 0.5;
  114. oKey.regY = oSprite.height * 0.5;
  115. return oKey;
  116. };
  117. this.unload = function () {
  118. createjs.Tween.removeAllTweens();
  119. createjs.Tween.get(_oGroup).to({alpha: 0}, 500, createjs.Ease.cubicIn).call(function () {
  120. s_oStage.removeChild(_oGroup);
  121. });
  122. var oParent = this;
  123. _oGroup.off("pressup", function () {
  124. oParent._onExitHelp();
  125. });
  126. };
  127. this._onExitHelp = function () {
  128. if (_bClick) {
  129. return;
  130. }
  131. _bClick = true;
  132. this.unload();
  133. s_oGame._onExitHelpPanel();
  134. };
  135. this._init(iXPos, iYPos, oSprite);
  136. return this;
  137. }