CAreYouSurePanel.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. function CAreYouSurePanel(oParentContainer) {
  2. var _oBg;
  3. var _oMsg;
  4. var _oButYes;
  5. var _oButNo;
  6. var _oContainer;
  7. var _oParentContainer;
  8. var _oFade;
  9. this._init = function () {
  10. _oContainer = new createjs.Container();
  11. _oContainer.alpha = 0;
  12. _oParentContainer.addChild(_oContainer);
  13. _oFade = new createjs.Shape();
  14. _oFade.graphics.beginFill("black").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
  15. _oFade.alpha = 0.5;
  16. _oFade.on("click", function () {});
  17. _oContainer.addChild(_oFade);
  18. var oSpriteBg = s_oSpriteLibrary.getSprite('msg_box');
  19. _oBg = createBitmap(oSpriteBg);
  20. _oBg.x = CANVAS_WIDTH_HALF;
  21. _oBg.y = CANVAS_HEIGHT_HALF;
  22. _oBg.regX = oSpriteBg.width * 0.5;
  23. _oBg.regY = oSpriteBg.height * 0.5;
  24. _oContainer.addChild(_oBg);
  25. _oMsg = new createjs.Text(TEXT_ARE_SURE, "70px " + FONT2, "#ffffff");
  26. _oMsg.x = CANVAS_WIDTH / 2 + 10;
  27. _oMsg.y = CANVAS_HEIGHT_HALF - 120;
  28. _oMsg.textAlign = "center";
  29. _oMsg.textBaseline = "middle";
  30. _oMsg.lineWidth = 450;
  31. _oContainer.addChild(_oMsg);
  32. _oButYes = new CGfxButton(CANVAS_WIDTH / 2 + 160, CANVAS_HEIGHT * 0.5 + 150, s_oSpriteLibrary.getSprite('but_yes'), _oContainer);
  33. _oButYes.addEventListener(ON_MOUSE_UP, this._onButYes, this);
  34. _oButNo = new CGfxButton(CANVAS_WIDTH / 2 - 160, CANVAS_HEIGHT * 0.5 + 150, s_oSpriteLibrary.getSprite('but_no'), _oContainer);
  35. _oButNo.addEventListener(ON_MOUSE_UP, this._onButNo, this);
  36. };
  37. this.show = function () {
  38. createjs.Tween.get(_oContainer).to({alpha: 1}, 150, createjs.quartOut).call(function () {
  39. s_oGame.pause(true);
  40. });
  41. };
  42. this.unload = function () {
  43. createjs.Tween.get(_oContainer).to({alpha: 0}, 150, createjs.quartOut).call(function () {
  44. _oParentContainer.removeChild(_oContainer, _oFade);
  45. });
  46. };
  47. this._onButYes = function () {
  48. createjs.Ticker.paused = false;
  49. this.unload();
  50. s_oGame.onExit();
  51. _oFade.removeAllEventListeners();
  52. };
  53. this._onButNo = function () {
  54. s_oGame.pause(false);
  55. this.unload();
  56. _oFade.removeAllEventListeners();
  57. };
  58. _oParentContainer = oParentContainer;
  59. this._init();
  60. }