var EHDI = EHDI || Object.create(null); EHDI.scene = EHDI.scene || Object.create(null); EHDI.scene.TitleScene = function() { EHDI.aka.Container.call(this); } EHDI.scene.TitleScene.prototype = Object.create(EHDI.aka.Container.prototype); EHDI.scene.TitleScene.prototype.screenWillAppear = function() { var bg = new EHDI.aka.Sprite(EHDI.Assets.images["title_egypt_bg"]); this.addChild(bg); //init dragonbones here //init guard DragonBones EHDI.GAME.components.Guard.initDB(); //init player DragonBones EHDI.GAME.components.Player.initDB(); }; EHDI.scene.TitleScene.prototype.screenDidAppear = function() { EHDI.GAME.soundManager.playBGM("escapeegypt", 0.7); this.title = new EHDI.aka.Sprite(EHDI.Assets.images["title_egypt_titlecard"]); this.title.anchor.set(0.5,0.5) this.title.x = EHDI.GAME.sceneManager.getStageWidth() * 0.5; this.title.y = EHDI.GAME.sceneManager.getStageHeight() * 0.5; this.lamp = new EHDI.aka.Sprite(EHDI.Assets.images["title_egypt_lamp"]); this.lamp.x = 140; this.lamp.y = 135; this.light = new EHDI.aka.Sprite(EHDI.Assets.images["title_egypt_light"]) this.light.x = this.lamp.x + this.lamp.width * 0.5; this.light.y = this.lamp.y + (this.lamp.height - this.light.height) * 0.35; this.tl = new TimelineMax(); this.tl.from(this.lamp, 0.3, {y: -this.lamp.height, ease: Power2.easeOut}) .from(this.light, 0.7, {alpha: 0, ease: Power3.easeOut}); // this.tl.to(this.title, 0.2, {y: this.title.y + 4, ease: Bounce.easeInOut}); this.addChild(this.light) this.addChild(this.lamp); this.addChild(this.title); 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(EHDI.GAME.sceneManager.getStageWidth() * 0.1, EHDI.GAME.sceneManager.getStageHeight() * 0.09); this.addChild(this.sound); this.highScoreHolder = new EHDI.components.HighScoreHolder(this, EHDI.GAME.saveData.highScore); this.highScoreHolder.setXY(EHDI.GAME.sceneManager.getStageWidth() * 0.723, EHDI.GAME.sceneManager.getStageHeight() * 0.0417); this.playBtn = new EHDI.displays.Button(EHDI.Assets.images["btn_play"], EHDI.Assets.images["btn_play2"], null, null); this.playBtn.position.set(EHDI.GAME.sceneManager.getStageWidth() * 0.5, EHDI.GAME.sceneManager.getStageHeight() * 0.85); this.addChild(this.playBtn); this.playBtn.setOnClickFunction(this.startGame); this.playTxt = new EHDI.aka.PixiText("PLAY", {fontFamily: 'proximanova-black', fill: 0xFFFFFF, fontSize : 32}); this.playTxt.anchor.set(0.75, 0.5); this.playBtn.addChild(this.playTxt); // this.tlPlayBtn = new TimelineMax({repeat: -1, yoyo: true}); // this.tlPlayBtn.to( this.playBtn.scale, 0.2, {x: 0.96, y: 0.96, ease: Power4.easeInOut}); this.tlLoop = new TimelineMax({repeat: -1, yoyo: true}); this.tlLoop.to( this.light, 0.2, {alpha: 0.5, ease: Power3.easeInOut, delay: 0.5}) .to( this.title.scale, 0.3, {x: 0.98 ,y: 0.98, ease: Power2.easeInOut}, 0.2) // if(!EHDI.GAME.debugUtils) { // EHDI.GAME.debugUtils = new EHDI.debugUtils.debugUtilsContainer("v0.2.4"); // EHDI.GAME.sceneManager.addNotification(EHDI.GAME.debugUtils); // } }; EHDI.scene.TitleScene.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, cache); } EHDI.scene.TitleScene.prototype.startGame = function() { EHDI.GAME.soundManager.playSFX("button_sfx"); EHDI.GAME.sceneManager.changeScene(new EHDI.GAME.scene.GameScene(), {x : new EHDI.scene.TransitionParameter(-EHDI.GAME.sceneManager.getStageWidth(), 0), duration : 0.25}); // EHDI.GAME.sceneManager.changeScene(new EHDI.scene.GameScene(), {x : new EHDI.scene.TransitionParameter(-EHDI.GAME.sceneManager.getStageWidth(), 0), duration : 0.25}); }; EHDI.scene.TitleScene.prototype.screenDidDisappear = function() { // this.tlPlayBtn.kill(); this.tlLoop.kill(); this.tl.kill(); this.sound.dispose(); this.playBtn.dispose(); this.destroy({children: true}); // delete this; }