CPause.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. function CPause() {
  2. var _oContainer;
  3. var _oFade;
  4. var _oButContinue;
  5. this._init = function () {
  6. var oContainer = new createjs.Container();
  7. oContainer.alpha = 1;
  8. _oFade = new createjs.Shape();
  9. _oFade.graphics.beginFill("black").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
  10. _oFade.alpha = 0.5;
  11. var oHitArea = new createjs.Shape();
  12. oHitArea.graphics.beginFill("#0f0f0f").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
  13. _oFade.hitArea = oHitArea;
  14. _oFade.on("click", function () {});
  15. oContainer.addChild(_oFade);
  16. var oSpriteBg = s_oSpriteLibrary.getSprite("msg_box");
  17. var oMsgBox = createBitmap(oSpriteBg);
  18. oMsgBox.x = CANVAS_WIDTH_HALF;
  19. oMsgBox.y = CANVAS_HEIGHT_HALF;
  20. oMsgBox.regX = oSpriteBg.width * 0.5;
  21. oMsgBox.regY = oSpriteBg.height * 0.5;
  22. oContainer.addChild(oMsgBox);
  23. var oPauseText = new createjs.Text(TEXT_PAUSE, "80px " + FONT2, "#ffffff");
  24. oPauseText.x = CANVAS_WIDTH * 0.5;
  25. oPauseText.y = CANVAS_HEIGHT * 0.5 - 200;
  26. oPauseText.textAlign = "center";
  27. oPauseText.lineWidth = 600;
  28. oContainer.addChild(oPauseText);
  29. var oSpriteContinue = s_oSpriteLibrary.getSprite("but_continue");
  30. _oButContinue = new CGfxButton(CANVAS_WIDTH * 0.5, CANVAS_HEIGHT * 0.5 + 70, oSpriteContinue, oContainer);
  31. _oButContinue.addEventListenerWithParams(ON_MOUSE_UP, this._onLeavePause, this, oContainer);
  32. // _oButContinue.setScale(0.6);
  33. _oButContinue.pulseAnimation();
  34. s_oStage.addChild(oContainer);
  35. s_oGame.pause(true);
  36. };
  37. this.unload = function () {
  38. _oFade.removeAllEventListeners();
  39. _oButContinue.unload();
  40. _oButContinue = null;
  41. s_oStage.removeChild(_oContainer);
  42. };
  43. this._onLeavePause = function (oContainer) {
  44. s_oGame.pause(false);
  45. createjs.Tween.get(oContainer).to({alpha: 0}, 100, createjs.quartIn).call(function () {
  46. s_oInterface.unloadPause();
  47. });
  48. };
  49. this._init();
  50. return this;
  51. }