CAreYouSurePanel.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. function CAreYouSurePanel(oParentContainer) {
  2. var _oMsgStroke;
  3. var _oMsg;
  4. var _oButYes;
  5. var _oButNo;
  6. var _oBg;
  7. var _oContainer;
  8. var _oFade;
  9. var _oParentContainer;
  10. this._init = function () {
  11. _oContainer = new createjs.Container();
  12. _oContainer.visible = false;
  13. _oParentContainer.addChild(_oContainer);
  14. _oFade = new createjs.Shape();
  15. _oFade.graphics.beginFill("black").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
  16. _oFade.alpha = 0.7;
  17. _oFade.on("click", function () {});
  18. _oContainer.addChild(_oFade);
  19. var oMsgBox = s_oSpriteLibrary.getSprite('msg_box');
  20. _oBg = createBitmap(oMsgBox);
  21. _oBg.x = CANVAS_WIDTH_HALF;
  22. _oBg.y = CANVAS_HEIGHT_HALF
  23. _oBg.regX = oMsgBox.width * 0.5;
  24. _oBg.regY = oMsgBox.height * 0.5;
  25. _oContainer.addChild(_oBg);
  26. _oBg.on("click", function () {});
  27. _oMsgStroke = new CTLText(_oContainer,
  28. CANVAS_WIDTH/2-300, CANVAS_HEIGHT * 0.5-150, 600, 150,
  29. 70, "center", "#0025c2", PRIMARY_FONT, 1,
  30. 0, 0,
  31. TEXT_ARE_SURE,
  32. true, true, true,
  33. false );
  34. _oMsgStroke.setOutline(5);
  35. _oMsg = new CTLText(_oContainer,
  36. CANVAS_WIDTH/2-300, CANVAS_HEIGHT * 0.5-150, 600, 150,
  37. 70, "center", "#ffd800", PRIMARY_FONT, 1,
  38. 0, 0,
  39. TEXT_ARE_SURE,
  40. true, true, true,
  41. false );
  42. _oButYes = new CGfxButton(CANVAS_WIDTH / 2 + 170, CANVAS_HEIGHT * 0.5 + 150, s_oSpriteLibrary.getSprite('but_yes'), _oContainer);
  43. _oButYes.addEventListener(ON_MOUSE_UP, this._onButYes, this);
  44. _oButNo = new CGfxButton(CANVAS_WIDTH / 2 - 170, CANVAS_HEIGHT * 0.5 + 150, s_oSpriteLibrary.getSprite('but_not'), _oContainer);
  45. _oButNo.addEventListener(ON_MOUSE_UP, this._onButNo, this);
  46. };
  47. this.onPause = function (bVal) {
  48. s_oGame.setPause(bVal);
  49. createjs.Ticker.paused = bVal;
  50. if (bVal === true) {
  51. s_oGame.canInput(false);
  52. } else {
  53. s_oGame.canInput(true);
  54. }
  55. };
  56. this.show = function () {
  57. this.onPause(true);
  58. _oContainer.visible = true;
  59. };
  60. this.unload = function () {
  61. _oButNo.unload();
  62. _oButYes.unload();
  63. _oFade.off("click", function () {});
  64. };
  65. this._onButYes = function () {
  66. this.unload();
  67. this.onPause(false);
  68. s_oGame.onExit();
  69. };
  70. this._onButNo = function () {
  71. this.unload();
  72. this.onPause(false);
  73. _oContainer.visible = false;
  74. };
  75. _oParentContainer = oParentContainer;
  76. this._init();
  77. }