CPause.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. function CPause() {
  2. var _oContainer;
  3. var _oFade;
  4. var _oLogo;
  5. this._init = function () {
  6. _oContainer = new createjs.Container();
  7. _oContainer.alpha = 0;
  8. _oFade = createBitmap(s_oSpriteLibrary.getSprite("bg_game"));
  9. _oFade.alpha = 1;
  10. _oFade.on("click", function () {});
  11. _oContainer.addChild(_oFade);
  12. var oSpriteLogo = s_oSpriteLibrary.getSprite("pause_text");
  13. _oLogo = createBitmap(oSpriteLogo);
  14. _oLogo.x = CANVAS_WIDTH_HALF;
  15. _oLogo.y = CANVAS_HEIGHT_HALF - 200;
  16. _oLogo.regX = oSpriteLogo.width * 0.5;
  17. _oLogo.regY = oSpriteLogo.height * 0.5;
  18. _oContainer.addChild(_oLogo);
  19. var oSpriteContinue = s_oSpriteLibrary.getSprite("but_continue");
  20. var oButContinue;
  21. oButContinue = new CGfxButton(CANVAS_WIDTH * 0.5, CANVAS_HEIGHT * 0.5 + 100, oSpriteContinue, _oContainer);
  22. oButContinue.addEventListener(ON_MOUSE_UP, this._onLeavePause, this);
  23. s_oStage.addChild(_oContainer);
  24. this.onPause(true);
  25. createjs.Tween.get(_oContainer).to({alpha: 1}, 300, createjs.quartOut).call(function () {
  26. createjs.Ticker.paused = true;
  27. });
  28. };
  29. this.onPause = function (bVal) {
  30. s_oGame.setPause(bVal);
  31. s_oGame.canInput(!bVal);
  32. };
  33. this.unload = function () {
  34. _oFade.off("click", function () {});
  35. s_oStage.removeChild(_oContainer);
  36. };
  37. this._onLeavePause = function () {
  38. createjs.Ticker.paused = false;
  39. createjs.Tween.removeTweens(_oContainer);
  40. var oParent = this;
  41. createjs.Tween.get(_oContainer).to({alpha: 0}, 300, createjs.quartIn).call(function () {
  42. oParent.onPause(false);
  43. s_oInterface.unloadPause();
  44. });
  45. };
  46. this._init();
  47. return this;
  48. }