CMsgBox.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. function CMsgBox(szText,oParentContainer){
  2. var _oMsgStroke;
  3. var _oMsg;
  4. var _oButOk;
  5. var _oThis;
  6. var _oContainer;
  7. var _oParentContainer;
  8. this._init = function (szText) {
  9. _oContainer = new createjs.Container();
  10. _oParentContainer.addChild(_oContainer);
  11. var oFade;
  12. oFade = new createjs.Shape();
  13. oFade.graphics.beginFill("black").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
  14. oFade.alpha = 0.5;
  15. oFade.on("click", function () {});
  16. _oContainer.addChild(oFade);
  17. var oSpriteBg = s_oSpriteLibrary.getSprite('msg_box');
  18. var oBg = createBitmap(oSpriteBg);
  19. oBg.x = CANVAS_WIDTH * 0.5;
  20. oBg.y = CANVAS_HEIGHT * 0.5;
  21. oBg.regX = oSpriteBg.width * 0.5;
  22. oBg.regY = oSpriteBg.height * 0.5;
  23. _oContainer.addChild(oBg);
  24. _oMsgStroke = new createjs.Text(szText, "30px " + FONT, "#000");
  25. _oMsgStroke.x = CANVAS_WIDTH / 2;
  26. _oMsgStroke.y = 360;
  27. _oMsgStroke.textAlign = "center";
  28. _oMsgStroke.textBaseline = "middle";
  29. _oMsgStroke.lineWidth = 400;
  30. _oMsgStroke.outline = 2;
  31. _oContainer.addChild(_oMsgStroke);
  32. _oMsg = new createjs.Text(_oMsgStroke.text, "30px " + FONT, "#ffc949");
  33. _oMsg.x = _oMsgStroke.x;
  34. _oMsg.y = _oMsgStroke.y;
  35. _oMsg.textAlign = "center";
  36. _oMsg.textBaseline = "middle";
  37. _oMsg.lineWidth = 400;
  38. _oContainer.addChild(_oMsg);
  39. _oButOk = new CGfxButton(CANVAS_WIDTH / 2, 700, s_oSpriteLibrary.getSprite('but_next'), _oContainer);
  40. _oButOk.addEventListener(ON_MOUSE_UP, this._onButOk, this);
  41. };
  42. this._onButOk = function () {
  43. _oThis.unload();
  44. };
  45. this.unload = function () {
  46. _oButOk.unload();
  47. _oParentContainer.removeChild(_oContainer);
  48. };
  49. _oThis = this;
  50. _oParentContainer = oParentContainer;
  51. this._init(szText);
  52. }