| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- function CGameOver(oSpriteBg, iScore, iLevel, iLines) {
- var _oGroup;
- var _oGroupMsgBox;
- var _oBg;
- var _oFade;
- var _oButMenu;
- var _oButRestart;
- this._init = function (oSpriteBg, iScore, iLevel, iLines) {
- s_oGame.setPause(true);
- _oGroup = new createjs.Container();
- _oGroupMsgBox = new createjs.Container();
- _oGroupMsgBox.y = -CANVAS_WIDTH_HALF - oSpriteBg.width * 0.5;
- _oBg = createBitmap(oSpriteBg);
- _oBg.x = CANVAS_WIDTH * 0.5;
- _oBg.y = CANVAS_HEIGHT * 0.5;
- _oBg.regX = oSpriteBg.width * 0.5;
- _oBg.regY = oSpriteBg.height * 0.5;
- _oGroupMsgBox.addChild(_oBg);
- _oFade = new createjs.Shape();
- _oFade.graphics.beginFill("black").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
- _oFade.alpha = 0;
- _oFade.on("click", function () {});
- _oGroup.addChild(_oFade);
- var pGameOverPos = {x: CANVAS_WIDTH * 0.5, y: CANVAS_HEIGHT * 0.5 - 75};
- var iSizeFont = 40;
- var iSizeFontGameOver = 60;
- var oTextLevel;
- var oTextLevelStruct;
- var oTextLines;
- var oTextLinesStruct;
- var oTextGameOverScore;
- var oTextGameOverScoreStruct;
- var oTextTitle;
- var oTextTitleStruct;
- oTextTitleStruct = new CTLText(_oGroupMsgBox,
- pGameOverPos.x-300, pGameOverPos.y - 150, 600, iSizeFontGameOver,
- iSizeFontGameOver, "center", "#0025c2", PRIMARY_FONT, 1,
- 0, 0,
- TEXT_GAMEOVER,
- true, true, false,
- false );
- oTextTitleStruct.setOutline(OUTLINE_TEXT);
- oTextTitle = new CTLText(_oGroupMsgBox,
- pGameOverPos.x-300, pGameOverPos.y-150, 600, iSizeFontGameOver,
- iSizeFontGameOver, "center", "#ffd800", PRIMARY_FONT, 1,
- 0, 0,
- TEXT_GAMEOVER,
- true, true, false,
- false );
-
- oTextLevelStruct = new CTLText(_oGroupMsgBox,
- pGameOverPos.x-300, pGameOverPos.y-25 , 250, iSizeFont*2,
- iSizeFont, "center", "#025cce", PRIMARY_FONT, 1,
- 0, 0,
- TEXT_LEVEL + "\n" + iLevel,
- true, true, true,
- false );
- oTextLevelStruct.setOutline(OUTLINE_TEXT);
-
- oTextLevel = new CTLText(_oGroupMsgBox,
- pGameOverPos.x-300, pGameOverPos.y-25, 250, iSizeFont*2,
- iSizeFont, "center", "#ffd800", PRIMARY_FONT, 1,
- 0, 0,
- TEXT_LEVEL + "\n" + iLevel,
- true, true, true,
- false );
-
-
- oTextLinesStruct = new CTLText(_oGroupMsgBox,
- pGameOverPos.x+50, pGameOverPos.y -25, 250, iSizeFont*2,
- iSizeFont, "center", "#025cce", PRIMARY_FONT, 1,
- 0, 0,
- TEXT_LINES + "\n" + iLines,
- true, true, true,
- false );
-
-
- oTextLinesStruct.setOutline(OUTLINE_TEXT);
- oTextLines = new CTLText(_oGroupMsgBox,
- pGameOverPos.x+50, pGameOverPos.y -25, 250, iSizeFont*2,
- iSizeFont, "center", "#ffd800", PRIMARY_FONT, 1,
- 0, 0,
- TEXT_LINES + "\n" + iLines,
- true, true, true,
- false );
-
-
- oTextGameOverScoreStruct = new CTLText(_oGroupMsgBox,
- pGameOverPos.x-150, pGameOverPos.y +100, 300, iSizeFont*3,
- iSizeFont, "center", "#025cce", PRIMARY_FONT, 1,
- 0, 0,
- TEXT_SCORE_GAMEOVER + "\n\n" + iScore,
- true, true, true,
- false );
-
-
- oTextGameOverScoreStruct.setOutline(4);
- oTextGameOverScore = new CTLText(_oGroupMsgBox,
- pGameOverPos.x-150, pGameOverPos.y +100, 300, iSizeFont*3,
- iSizeFont, "center", "#ffd800", PRIMARY_FONT, 1,
- 0, 0,
- TEXT_SCORE_GAMEOVER + "\n\n" + iScore,
- true, true, true,
- false );
-
-
- _oGroup.addChild(_oGroupMsgBox);
- s_oStage.addChild(_oGroup);
- var oSpriteRestart = s_oSpriteLibrary.getSprite("but_restart");
- var oSpriteHome = s_oSpriteLibrary.getSprite("but_home");
- _oButMenu = new CGfxButton((CANVAS_WIDTH / 2 - 250), CANVAS_HEIGHT / 2 + 150, oSpriteHome, _oGroupMsgBox);
- _oButMenu.addEventListener(ON_MOUSE_UP, this._onMenu, this);
- _oButRestart = new CGfxButton((CANVAS_WIDTH / 2 + 250), CANVAS_HEIGHT / 2 + 150, oSpriteRestart, _oGroupMsgBox);
- _oButRestart.addEventListener(ON_MOUSE_UP, this._onRestart, this);
- _oButRestart.pulseAnimation();
- createjs.Tween.get(_oFade).to({alpha: 0.5}, 750, createjs.Ease.cubicOut);
- createjs.Tween.get(_oGroupMsgBox).to({y: 0}, 1500, createjs.Ease.bounceOut).call(function () {
- if (s_iAdsLevel === NUM_LEVEL_FOR_ADS) {
- $(s_oMain).trigger("show_interlevel_ad");
- s_iAdsLevel = 1;
- } else {
- s_iAdsLevel++;
- }
- });
- $(s_oMain).trigger("save_score", iScore);
- $(s_oMain).trigger("share_event", iScore);
- };
- this.unload = function () {
- _oFade.off("click", function () {});
- if (_oButMenu) {
- _oButMenu.unload();
- _oButMenu = null;
- }
- s_oStage.removeChild(_oGroup);
- };
- this._onMenu = function () {
- this.unload();
- s_oInterface._onButMenuRelease();
- };
- this._onRestart = function () {
- this.unload();
- s_oInterface._onButRestartLevelRelease();
- };
- this._init(oSpriteBg, iScore, iLevel, iLines);
- return this;
- }
|