var EHDI = EHDI || Object.create(null); EHDI.scene = EHDI.scene || Object.create(null); EHDI.scene.TitleScene = function() { EHDI.aka.Container.call(this); this.spark = 1; } 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_pp_bg"]); this.addChild(bg); }; EHDI.scene.TitleScene.prototype.screenDidAppear = function() { EHDI.GAME.soundManager.sfxVolume = 0.5; this.gizmo = new EHDI.aka.Sprite(EHDI.Assets.images["title_pp_gizmo"]); this.gizmo.anchor.set(0.5, 0.5); this.gizmo.position.set(EHDI.GAME.sceneManager.getStageWidth() * 0.5, EHDI.GAME.sceneManager.getStageHeight() * 0.35); this.addChild(this.gizmo); this.glow = new EHDI.aka.Sprite(EHDI.Assets.images["title_pp_grid_glow"]); this.glow.anchor.set(0.5, 0.5); this.glow.position.set(EHDI.GAME.sceneManager.getStageWidth() * 0.5, EHDI.GAME.sceneManager.getStageHeight() * 0.5); this.addChild(this.glow); this.patternLeft = new EHDI.aka.Sprite(EHDI.Assets.images["title_pp_pattern_left"]); this.patternLeft.anchor.set(0.5, 0.5); this.patternLeft.position.set(EHDI.GAME.sceneManager.getStageWidth() * 0.275, EHDI.GAME.sceneManager.getStageHeight() * 0.6); this.addChild(this.patternLeft); this.patternRight = new EHDI.aka.Sprite(EHDI.Assets.images["title_pp_pattern_right"]); this.patternRight.anchor.set(0.5, 0.5); this.patternRight.position.set(EHDI.GAME.sceneManager.getStageWidth() * 0.725, EHDI.GAME.sceneManager.getStageHeight() * 0.5); this.addChild(this.patternRight); this.left = new EHDI.aka.Sprite(EHDI.Assets.images["title_pp_bracket"]); this.left.anchor.set(0, 0.5); this.left.position.set(EHDI.GAME.sceneManager.getStageWidth() * 0.325, EHDI.GAME.sceneManager.getStageHeight() * 0.5); this.addChild(this.left); this.right = new EHDI.aka.Sprite(EHDI.Assets.images["title_pp_bracket"]); this.right.anchor.set(0, 0.5); this.right.position.set(EHDI.GAME.sceneManager.getStageWidth() * 0.675, EHDI.GAME.sceneManager.getStageHeight() * 0.5); this.addChild(this.right); this.right.scale.x = -1; this.pattern = new EHDI.aka.Sprite(EHDI.Assets.images["title_pp_txt_pattern"]); this.pattern.anchor.set(0.5, 0.5); this.pattern.position.set(EHDI.GAME.sceneManager.getStageWidth() * 0.5, EHDI.GAME.sceneManager.getStageHeight() * 0.4); this.addChild(this.pattern); this.panic = new EHDI.aka.Sprite(EHDI.Assets.images["title_pp_txt_panic"]); this.panic.anchor.set(0.5, 0.5); this.panic.position.set(EHDI.GAME.sceneManager.getStageWidth() * 0.5, EHDI.GAME.sceneManager.getStageHeight() * 0.6); this.addChild(this.panic); this.effect = new EHDI.aka.Sprite(EHDI.Assets.images["title_pp_spark1"]); this.effect.anchor.set(0.5, 0.5); this.effect.position.set(EHDI.GAME.sceneManager.getStageWidth() * 0.5, EHDI.GAME.sceneManager.getStageHeight() * 0.6); this.addChild(this.effect); 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.visible = false; this.playBtn.alpha = 0; this.playBtn.setOnClickFunction(this.startGame.bind(this)); 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.entranceTimeline = new TimelineMax(); this.entranceTimeline.from(this.glow.scale, 0.2, {y : 0}); this.entranceTimeline.from(this.left.scale, 0.2, {y : 0}, 0); this.entranceTimeline.from(this.right.scale, 0.2, {y : 0}, 0); this.entranceTimeline.from(this.left, 0.15, {x : EHDI.GAME.sceneManager.getStageWidth() * 0.425}); this.entranceTimeline.from(this.right, 0.15, {x : EHDI.GAME.sceneManager.getStageWidth() * 0.575}, "-= 0.15"); this.entranceTimeline.from(this.glow.scale, 0.15, {x : 0}, "-=0.15"); this.entranceTimeline.from(this.pattern.scale, 0.2, {x : 0}, "-=0.1"); this.entranceTimeline.from(this.panic.scale, 0.2, {x : 0}, "-=0.2"); this.entranceTimeline.from(this.effect.scale, 0.2, {x : 0}, "-=0.2"); this.entranceTimeline.from(this.patternLeft, 0.4, {x : EHDI.GAME.sceneManager.getStageWidth() * 0.425, alpha : 0}, "-=0.05"); this.entranceTimeline.from(this.patternRight, 0.4, {x : EHDI.GAME.sceneManager.getStageWidth() * 0.575, alpha : 0}, "-=0.4"); this.entranceTimeline.add(this.loopAnimation.bind(this)); this.entranceTimeline.to(this.playBtn, 0.1, {alpha : 1}); /* if(!EHDI.GAME.debugUtils) { EHDI.GAME.debugUtils = new EHDI.debugUtils.debugUtilsContainer("v0.2.5"); EHDI.GAME.sceneManager.addNotification(EHDI.GAME.debugUtils); }*/ EHDI.GAME.soundManager.playBGM("patternpanic_bgm"); }; EHDI.scene.TitleScene.prototype.loopAnimation = function() { this.loopTimeline = new TimelineMax({repeat : -1}); this.loopTimeline.to(this.effect, 0, {alpha : 1}, "+=0.1"); this.loopTimeline.to(this.effect, 0, {alpha : 0}, "+=0.05"); this.loopTimeline.to(this.effect, 0, {alpha : 1}, "+=0.1"); this.loopTimeline.to(this.effect, 0, {alpha : 0}, "+=0.05"); this.loopTimeline.to(this.effect, 0, {alpha : 1}, "+=0.1"); this.loopTimeline.to(this.effect, 0, {alpha : 0}, "+=0.05"); this.loopTimeline.add(this.changeSpark.bind(this)); var leftPos = this.patternLeft.x, rightPos = this.patternRight.x; this.shakeTimeline = new TimelineMax({repeat : -1, repeatDelay : 1.25}); this.shakeTimeline.to(this.patternLeft, 0.04, {x : leftPos + EHDI.GAME.sceneManager.getStageWidth () * 0.005, ease : Power0.easeNone}); this.shakeTimeline.to(this.patternRight, 0.04, {x : rightPos - EHDI.GAME.sceneManager.getStageWidth () * 0.005, ease : Power0.easeNone}, 0); this.shakeTimeline.to(this.patternLeft, 0.08, {x : leftPos - EHDI.GAME.sceneManager.getStageWidth () * 0.01, ease : Power0.easeNone}); this.shakeTimeline.to(this.patternRight, 0.08, {x : rightPos + EHDI.GAME.sceneManager.getStageWidth () * 0.01, ease : Power0.easeNone}, "-=0.1"); this.shakeTimeline.to(this.patternLeft, 0.04, {x : leftPos, ease : Power0.easeNone}); this.shakeTimeline.to(this.patternRight, 0.04, {x : rightPos, ease : Power0.easeNone}, "-=0.05"); this.shakeTimeline.to(this.patternLeft, 0.04, {x : leftPos + EHDI.GAME.sceneManager.getStageWidth () * 0.005, ease : Power0.easeNone}); this.shakeTimeline.to(this.patternRight, 0.04, {x : rightPos - EHDI.GAME.sceneManager.getStageWidth () * 0.005, ease : Power0.easeNone}, 0); this.shakeTimeline.to(this.patternLeft, 0.08, {x : leftPos - EHDI.GAME.sceneManager.getStageWidth () * 0.01, ease : Power0.easeNone}); this.shakeTimeline.to(this.patternRight, 0.08, {x : rightPos + EHDI.GAME.sceneManager.getStageWidth () * 0.01, ease : Power0.easeNone}, "-=0.1"); this.shakeTimeline.to(this.patternLeft, 0.04, {x : leftPos, ease : Power0.easeNone}); this.shakeTimeline.to(this.patternRight, 0.04, {x : rightPos, ease : Power0.easeNone}, "-=0.05"); this.shakeTimeline.to(this.patternLeft, 0.04, {x : leftPos + EHDI.GAME.sceneManager.getStageWidth () * 0.005, ease : Power0.easeNone}); this.shakeTimeline.to(this.patternRight, 0.04, {x : rightPos - EHDI.GAME.sceneManager.getStageWidth () * 0.005, ease : Power0.easeNone}, 0); this.shakeTimeline.to(this.patternLeft, 0.08, {x : leftPos - EHDI.GAME.sceneManager.getStageWidth () * 0.01, ease : Power0.easeNone}); this.shakeTimeline.to(this.patternRight, 0.08, {x : rightPos + EHDI.GAME.sceneManager.getStageWidth () * 0.01, ease : Power0.easeNone}, "-=0.1"); this.shakeTimeline.to(this.patternLeft, 0.04, {x : leftPos, ease : Power0.easeNone}); this.shakeTimeline.to(this.patternRight, 0.04, {x : rightPos, ease : Power0.easeNone}, "-=0.05"); this.playBtn.visible = true; this.playBtnTimeline = new TimelineMax({repeat : -1, repeatDelay : 1.5, delay : 3}); this.playBtnTimeline.to(this.playBtn.scale, 0.1, {x : 1.1, y: 1.2}); this.playBtnTimeline.to(this.playBtn.scale, 0.1, {x : 1, y: 1}); this.playBtnTimeline.to(this.playBtn.scale, 0.1, {x : 1.1, y: 1.2}); this.playBtnTimeline.to(this.playBtn.scale, 0.1, {x : 1, y: 1}); this.playBtn.touchstart = (function(touchstart, titlescene) { return function() { titlescene.playBtn.scale.set(1, 1); titlescene.playBtnTimeline.pause(); return touchstart.apply(this, arguments); } }(this.playBtn.touchstart, this)); this.playBtn.mousedown = (function(mousedown, titlescene) { return function() { titlescene.playBtn.scale.set(1, 1); titlescene.playBtnTimeline.pause(); return mousedown.apply(this, arguments); } }(this.playBtn.mousedown, this)); this.playBtn.touchendoutside = (function(touchendoutside, titlescene) { return function() { titlescene.playBtnTimeline.restart() titlescene.playBtnTimeline.play(); return touchendoutside.apply(this, arguments); } }(this.playBtn.touchendoutside, this)); this.playBtn.mouseout = (function(mouseout, titlescene) { return function() { if(titlescene.playBtnTimeline){ titlescene.playBtnTimeline.restart() titlescene.playBtnTimeline.play(); } return mouseout.apply(this, arguments); } }(this.playBtn.mouseout, this)); }; EHDI.scene.TitleScene.prototype.changeSpark = function() { this.spark++; if(this.spark > 2) this.spark = 1; this.effect.texture = EHDI.Assets.images["title_pp_spark" + this.spark]; }; EHDI.scene.TitleScene.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, cache); EHDI.GAME.soundManager.playSFX("button_sfx"); }; EHDI.scene.TitleScene.prototype.startGame = function() { this.loopTimeline.kill(); this.shakeTimeline.kill(); this.playBtnTimeline.kill(); this.shakeTimeline = null; this.loopTimeline = null; this.playBtnTimeline = null; this.entranceTimeline.kill(); EHDI.GAME.soundManager.playSFX("button_sfx"); 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.destroy({children: true}); delete this; }