var EHDI = EHDI || Object.create(null); EHDI.popup = EHDI.popup || Object.create(null); EHDI.popup.PausePopUp = function() { EHDI.aka.Container.call(this); }; EHDI.popup.PausePopUp.prototype = Object.create(EHDI.aka.Container.prototype); EHDI.popup.PausePopUp.prototype.popUpWillAppear = function() { 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 = []; for(var i = 0; i < 4; i++){ this.htps[i] = Object.create(null); this.htps[i].img = new EHDI.aka.Sprite(EHDI.Assets.images["htp_parabuilder"+(i+1)]); this.htps[i].desc = new EHDI.displays.TextSprite(EHDI.GAME.JSONMgr.getLocale("HTP_FORMAT")); this.htps[i].img.anchor.set(0.5,0.5) this.htps[i].img.position.set(this.bg.x, this.bg.y - 60); this.htps[i].desc.anchor.set(0.5,0.5) this.htps[i].desc.position.set(this.bg.x, this.bg.y + 60); this.addChild(this.htps[i].img); this.addChild(this.htps[i].desc); } this.currentHtp = 0; this.setHTP(); this.htps[1].img.visible = false; this.htps[1].desc.visible = false; this.htps[0].desc.text = EHDI.GAME.JSONMgr.getLocale("LBL_HTP1").TEXT; this.htps[1].desc.text = EHDI.GAME.JSONMgr.getLocale("LBL_HTP2").TEXT; this.htps[2].desc.text = EHDI.GAME.JSONMgr.getLocale("LBL_HTP3").TEXT; this.htps[3].desc.text = EHDI.GAME.JSONMgr.getLocale("LBL_HTP4").TEXT; }; EHDI.popup.PausePopUp.prototype.popUpDidAppear = function() { this.overlay.alpha = 0.5; this.overlay.interactive = true; // this.pausedTxt = new EHDI.aka.PixiText("GAME PAUSED", {fontFamily: "Exo-Bold", fill: 0xFFFFFF, fontSize : 50}); this.pausedTxt = new EHDI.displays.TextSprite(EHDI.GAME.JSONMgr.getLocale("LBL_PAUSE_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.next = new EHDI.displays.Button(EHDI.Assets.images["btn_prevnext"], EHDI.Assets.images["btn_prevnext2"], null, null); this.bg.addChild(this.next); this.next.position.set(this.bg.width * 0.45, 0); this.next.setOnClickFunction(this.nextPage.bind(this)); this.previous = new EHDI.displays.Button(EHDI.Assets.images["btn_prevnext"], EHDI.Assets.images["btn_prevnext2"], null, null); this.bg.addChild(this.previous); this.previous.position.set(-this.bg.width * 0.45, 0); this.previous.scale.x = -1; this.previous.setOnClickFunction(this.previousPage.bind(this)); 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); this.exit = new EHDI.displays.Button(EHDI.Assets.images["btn_exit"], EHDI.Assets.images["btn_exit2"], null, null); this.bg.addChild(this.exit); this.exit.position.set(-this.bg.width * 0.3, this.bg.height * 0.35); this.exit.setOnClickFunction(this.exitGame.bind(this)); this.sound = new EHDI.displays.ToggleButton(EHDI.Assets.images["btn_audio1"], EHDI.Assets.images["btn_audio3"], EHDI.Assets.images["btn_audio2"], EHDI.Assets.images["btn_audio4"], EHDI.GAME.soundManager.getMuted()); this.sound.setOnClickFunction(this.toggleAudio); this.sound.position.set(this.bg.width * 0.3, this.bg.height * 0.35); this.bg.addChild(this.sound); }; EHDI.popup.PausePopUp.prototype.popUpWillDisappear = function() { this.overlay.alpha = 0; } EHDI.popup.PausePopUp.prototype.popUpDidDisappear = function() { while(this.htps.length > 0){ var pop = this.htps.pop(); pop.img.destroy({children: true}); pop.desc.destroy(); } this.sound.dispose(); this.return.dispose(); this.previous.dispose(); this.next.dispose(); this.exit.dispose(); EHDI.GAME.pauseButton.resumeGame(); this.destroy({children: true}); } EHDI.popup.PausePopUp.prototype.toggleAudio = function(enable) { EHDI.GAME.soundManager.setMute(enable); EHDI.GAME.soundManager.playSFX("button_sfx"); var cache = EHDI.GAME.storageManager.getLocalInfo(EHDI.GAME.id); cache.isMuted = enable; EHDI.GAME.storageManager.setLocalInfo(EHDI.GAME.id, enable); } EHDI.popup.PausePopUp.prototype.resumeGame = function() { EHDI.GAME.soundManager.playSFX("button_sfx"); EHDI.GAME.sceneManager.popPopUp({y : new EHDI.scene.TransitionParameter(EHDI.GAME.sceneManager.getStageHeight() * 0.5, -EHDI.GAME.sceneManager.getStageHeight()), duration : 0.25}); } EHDI.popup.PausePopUp.prototype.exitGame = function() { EHDI.GAME.soundManager.playSFX("button_sfx"); // EHDI.GAME.sceneManager.popAllPopUps(); 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.PausePopUp.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}); }; EHDI.popup.PausePopUp.prototype.setHTP = function(){ for(var i = 0; i < this.htps.length; i++){ this.htps[i].img.visible = false; this.htps[i].desc.visible = false; } this.htps[this.currentHtp].img.visible = true; this.htps[this.currentHtp].desc.visible = true; } EHDI.popup.PausePopUp.prototype.nextPage = function() { //IMPLEMENT NEXT PAGE EHDI.GAME.soundManager.playSFX("button_sfx"); this.currentHtp++; if(this.currentHtp >= this.htps.length) this.currentHtp = 0; this.setHTP(); }; EHDI.popup.PausePopUp.prototype.previousPage = function() { //IMPLEMENT PREVIOUS PAGE EHDI.GAME.soundManager.playSFX("button_sfx"); this.currentHtp--; if(this.currentHtp < 0) this.currentHtp = this.htps.length-1; this.setHTP(); };