CHelpPanel.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. function CHelpPanel(iXPos, iYPos, oSprite) {
  2. var _oTitle;
  3. var _oTitleStroke;
  4. var _oHelpBg;
  5. var _oFade;
  6. var _oGroup;
  7. var _oContainerAnim;
  8. var _bClick = false;
  9. this._init = function (iXPos, iYPos, oSprite) {
  10. _oGroup = new createjs.Container();
  11. _oGroup.x = iXPos;
  12. _oGroup.y = iYPos;
  13. s_oStage.addChild(_oGroup);
  14. _oFade = new createjs.Shape();
  15. _oFade.graphics.beginFill("black").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
  16. _oFade.alpha = 0.7;
  17. _oGroup.addChild(_oFade);
  18. _oHelpBg = createBitmap(oSprite);
  19. _oHelpBg.x = CANVAS_WIDTH_HALF;
  20. _oHelpBg.y = CANVAS_HEIGHT_HALF;
  21. _oHelpBg.regX = oSprite.width * 0.5;
  22. _oHelpBg.regY = oSprite.height * 0.5;
  23. _oGroup.addChild(_oHelpBg);
  24. _oTitleStroke = new CTLText(_oGroup,
  25. CANVAS_WIDTH/2-300, CANVAS_HEIGHT * 0.5 - 230, 600, 50,
  26. 50, "center", "#0025c2", PRIMARY_FONT, 1,
  27. 0, 0,
  28. TEXT_HOW_TO_PLAY,
  29. true, true, false,
  30. false );
  31. _oTitleStroke.setOutline(4);
  32. _oTitle = new CTLText(_oGroup,
  33. CANVAS_WIDTH/2-300, CANVAS_HEIGHT * 0.5 - 230, 600, 50,
  34. 50, "center", "#ffd800", PRIMARY_FONT, 1,
  35. 0, 0,
  36. TEXT_HOW_TO_PLAY,
  37. true, true, false,
  38. false );
  39. _oContainerAnim = new createjs.Container();
  40. var oSpriteKeyLeft;
  41. var oSpriteKeyUp;
  42. var oSpriteKeyRight;
  43. var oSpriteKeyDown;
  44. if (!s_bMobile) {
  45. oSpriteKeyLeft = s_oSpriteLibrary.getSprite("key_left");
  46. oSpriteKeyUp = s_oSpriteLibrary.getSprite("key_up");
  47. oSpriteKeyRight = s_oSpriteLibrary.getSprite("key_right");
  48. oSpriteKeyDown = s_oSpriteLibrary.getSprite("key_down");
  49. } else {
  50. oSpriteKeyLeft = s_oSpriteLibrary.getSprite("arrow");
  51. oSpriteKeyUp = s_oSpriteLibrary.getSprite("arrow");
  52. oSpriteKeyRight = s_oSpriteLibrary.getSprite("arrow");
  53. oSpriteKeyDown = s_oSpriteLibrary.getSprite("but_rotation");
  54. }
  55. var oBlockBlur = this.createKey(CANVAS_WIDTH_HALF, CANVAS_HEIGHT_HALF - 100, s_oSpriteLibrary.getSprite("block_blur"));
  56. var oBlockDown = this.createKey(CANVAS_WIDTH_HALF - 125, CANVAS_HEIGHT_HALF + 30, s_oSpriteLibrary.getSprite("block_down"));
  57. var oBlockRotation = this.createKey(CANVAS_WIDTH_HALF + 125, CANVAS_HEIGHT_HALF + 30, s_oSpriteLibrary.getSprite("block_rotation"));
  58. var oKeyLeft = this.createKey(CANVAS_WIDTH_HALF - 135, CANVAS_HEIGHT_HALF - 90, oSpriteKeyLeft);
  59. var oKeyUp = this.createKey(CANVAS_WIDTH_HALF + 125, CANVAS_HEIGHT_HALF + 170, oSpriteKeyUp);
  60. var oKeyRight = this.createKey(CANVAS_WIDTH_HALF + 135, CANVAS_HEIGHT_HALF - 90, oSpriteKeyRight);
  61. var oKeyDown = this.createKey(CANVAS_WIDTH_HALF - 125, CANVAS_HEIGHT_HALF + 170, oSpriteKeyDown);
  62. if (s_bMobile) {
  63. oKeyLeft.scaleX = -1;
  64. oKeyUp.rotation = 270;
  65. }
  66. _oContainerAnim.addChild(oKeyLeft, oKeyUp, oKeyRight, oKeyDown, oBlockBlur, oBlockDown, oBlockRotation);
  67. _oGroup.addChild(_oContainerAnim);
  68. if(!s_bMobile){
  69. _oGroup.cursor="pointer";
  70. }
  71. var oParent = this;
  72. _oGroup.on("pressup", function () {
  73. oParent._onExitHelp();
  74. });
  75. };
  76. this.createKey = function (iX, iY, oSprite) {
  77. var oKey;
  78. oKey = createBitmap(oSprite);
  79. oKey.x = iX;
  80. oKey.y = iY;
  81. oKey.regX = oSprite.width * 0.5;
  82. oKey.regY = oSprite.height * 0.5;
  83. return oKey;
  84. };
  85. this.unload = function () {
  86. createjs.Tween.removeAllTweens();
  87. createjs.Tween.get(_oGroup).to({alpha: 0}, 500, createjs.Ease.cubicIn).call(function () {
  88. s_oStage.removeChild(_oGroup);
  89. });
  90. var oParent = this;
  91. _oGroup.off("pressup", function () {
  92. oParent._onExitHelp();
  93. });
  94. };
  95. this._onExitHelp = function () {
  96. if (_bClick) {
  97. return;
  98. }
  99. _bClick = true;
  100. this.unload();
  101. s_oGame._onExitHelpPanel();
  102. };
  103. this._init(iXPos, iYPos, oSprite);
  104. return this;
  105. }