var EHDI = EHDI || Object.create(null); EHDI.popup = EHDI.popup || Object.create(null); EHDI.popup.HTPPopUp = function(callback) { EHDI.aka.Container.call(this); this.resumeCallback = callback; }; EHDI.popup.HTPPopUp.prototype = Object.create(EHDI.aka.Container.prototype); EHDI.popup.HTPPopUp.prototype.popUpWillAppear = function() { ITW.GameMgr.setPaused(true); ITW.SoundMgr.pauseBGM(); ITW.SoundMgr.pauseAllSFX(); this.overlay = EHDI.displays.FillRectangle(0x000000, 0, 0, EHDI.GAME.sceneManager.getStageWidth(), EHDI.GAME.sceneManager.getStageHeight(),0); this.overlay.anchor.set(0.5, 0.5); this.addChild(this.overlay); this.position.x = EHDI.GAME.sceneManager.getStageWidth() * 0.5; this.bg = new EHDI.aka.Sprite(EHDI.Assets.images["gfx_pop"]); this.bg.anchor.set(0.5, 0.5); this.addChild(this.bg); this.htps = Object.create(null); this.htps.img = new EHDI.aka.Sprite(EHDI.Assets.images["htp_bigfish"]); this.htps.desc = new EHDI.displays.TextSprite(EHDI.GAME.JSONMgr.getLocale("HTP_FORMAT")); // this.htps.desc = new EHDI.aka.PixiText("", { // fontFamily: 'Exo-Bold', // fontWeight: 'bold', // fill: 0xFFFFFF, // fontSize : 24, // wordWrap: true, // wordWrapWidth: this.bg.width * 0.65, // align: "center" // }); this.htps.img.anchor.set(0.5,0.5) this.htps.img.position.set(this.bg.x, this.bg.y - 60); this.htps.desc.anchor.set(0.5,0.5) this.htps.desc.position.set(this.bg.x, this.bg.y + 60); this.addChild(this.htps.img); this.addChild(this.htps.desc); this.htps.desc.text = EHDI.GAME.JSONMgr.getLocale("LBL_HTP").TEXT; }; EHDI.popup.HTPPopUp.prototype.popUpDidAppear = function() { this.overlay.alpha = 0.5; this.overlay.interactive = true; // this.pausedTxt = new EHDI.aka.PixiText("HOW TO PLAY", {fontFamily: "Exo-Bold", fill: 0xFFFFFF, fontSize : 50}); this.pausedTxt = new EHDI.displays.TextSprite(EHDI.GAME.JSONMgr.getLocale("LBL_HTP_HEADER")); this.pausedTxt.anchor.set(0.5, 0.5); this.pausedTxt.position.set(-this.bg.width * 0.2, -this.bg.width * 0.24); this.bg.addChild(this.pausedTxt); this.return = new EHDI.displays.Button(EHDI.Assets.images["btn_return"], EHDI.Assets.images["btn_return2"], null, null); this.bg.addChild(this.return); this.return.position.set(0, this.bg.height * 0.35); this.return.setOnClickFunction(this.resumeGame.bind(this)); }; EHDI.popup.HTPPopUp.prototype.popUpWillDisappear = function() { this.overlay.alpha = 0; ITW.SoundMgr.resumeBGM(); ITW.SoundMgr.resumeAllSFX(); } EHDI.popup.HTPPopUp.prototype.popUpDidDisappear = function() { EHDI.GAME.pauseButton.resumeGame(); } EHDI.popup.HTPPopUp.prototype.toggleAudio = function(enable) { EHDI.GAME.soundManager.setMute(enable); var cache = EHDI.GAME.storageManager.getLocalInfo(EHDI.GAME.id); cache.isMuted = enable; EHDI.GAME.storageManager.setLocalInfo(EHDI.GAME.id, enable); } EHDI.popup.HTPPopUp.prototype.resumeGame = function() { EHDI.GAME.soundManager.playSFX("button_sfx"); var data = EHDI.GAME.saveData; if(data.isFirstTimePlay){ data.isFirstTimePlay = false; EHDI.sbGame.saveGameData(EHDI.GAME.saveData, "DEFAULT", function(){ console.log("data saved."); }); } if(typeof this.resumeCallback === "function"){ this.resumeCallback(); ITW.GameMgr.setPaused(false); } EHDI.GAME.sceneManager.popPopUp({y : new EHDI.scene.TransitionParameter(EHDI.GAME.sceneManager.getStageHeight() * 0.5, -EHDI.GAME.sceneManager.getStageHeight()), duration : 0.25}); } EHDI.popup.HTPPopUp.prototype.exitGame = function() { EHDI.GAME.soundManager.playSFX("button_sfx"); EHDI.GAME.sceneManager.pushPopUp(new EHDI.popup.ConfirmationPopup(this.goToTitleScreen.bind(this), null), {y : new EHDI.scene.TransitionParameter(EHDI.GAME.sceneManager.getStageHeight(), 0), duration : 0.25}); }; EHDI.popup.HTPPopUp.prototype.goToTitleScreen = function() { EHDI.GAME.pauseButton.isEndGame = true; EHDI.GAME.sceneManager.popPopUp(); EHDI.GAME.sceneManager.changeScene(new EHDI.scene.TitleScene(), {alpha : new EHDI.scene.TransitionParameter(0,1), duration : 0.25}); };