OwlCyberSecurity - MANAGER
Edit File: titlescreen.js
var titleScreen = function(game) { MuteBool = false; gamepaused = false; GameTitle = "equestria_girls_avatar_maker"; } var initialized = false; var initGDApi = function(){ if(!initialized){ // Api will be initialized once, so preroll is shown once either var settings = { gameId: "fddfe12517cb401c866192bea7e21d49", userId: "0D5F5E86-FEB8-421A-8930-103B37748096-s1", resumeGame: resumeGame, pauseGame: pauseGame, onInit: function (data) { initialized = true; }, onError: function (data) { console.log("Error:"+data); } }; (function(i,s,o,g,r,a,m){ i['GameDistribution']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)};i[r].l=1*new Date();a=s.createElement(o);m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a, m); })(window, document, 'script', '//html5.api.gamedistribution.com/libs/gd/api.js', 'gdApi'); gdApi(settings); function resumeGame() { console.log("Resume game"); gamepaused = false; } function pauseGame() { console.log("Pause game"); gamepaused = true; } } } titleScreen.prototype = { create: function() { //this.game.renderer.renderSession.roundPixels = true; //add the background music BgMusic = this.add.audio("backgroundmusic"); //.loop = true will make the background music loop BgMusic.loop = true; //set the BgMusic volume to 0.7. 1 is default BgMusic.volume = 1; //we then play the background music BgMusic.play(); //add the Play button sound effects PlaySfx = this.add.audio("playsfx"); //add the starsue logo sound effects in the dress up scene StarsueSfx = this.add.audio("starsuesfx"); /*I added this two variables for you to save some time typing this.world.centerX and centerY to make the graphics appear in the middle of the screen*/ CenterX = this.world.centerX; CenterY = this.world.centerY; //add the Background image Background = this.add.image(0,-.5,"background"); //Doll Intro_Character = this.add.sprite(302,774,"intro_character"); Intro_Character.anchor.setTo(0.5,0.5); //Intro_Character.smoothed = false; //add the title of the game Title = this.add.image(751,252,"title"); Title.anchor.setTo(0.5,0.5); //add the Play Button sprite Play_Btn = this.add.button(726,534,"play_btn",function() { initGDApi(); this.state.start("DressUp"); },this,1,0,2); Play_Btn.anchor.setTo(0.5,0.5); Logo = this.add.button(0,0,"logo",function() { window.open("http://www.kawaiigames.net/?utm_source="+ GameTitle + "&utm_medium=html5game","_blank"); },this,1,0,2); Logo.anchor.setTo(0.5,0.5); Logo.x = 81; Logo.y = 538; Credits_Btn = this.add.button(0,0,"credits_btn",function() { //hide the Credits_Btn Credits_Btn.visible = false; //make the Credits_Group visible Credits_Group.visible = true; //disable all buttons that is not meant to be clickable when Credits shows up Play_Btn.inputEnabled = false; },this,1,0,2); Credits_Btn.anchor.setTo(0.5,0.5); Credits_Btn.x = 75; Credits_Btn.y = 614; //---------------------------------------------------------// //Credits Screen //Screen_Effect (black screen at the back of the credits screen) //the first 0 is the x and the second 0 is the y Screen_Effect = this.add.sprite(0,0,"screen_effect"); //Credits_Text includes the credits text and the pink border Credits_Text = this.add.sprite(0,0,"credits_text"); Credits_Text.anchor.setTo(0.5,0.5); Credits_Text.x = CenterX; Credits_Text.y = CenterY; Link_Btn = this.add.button(592,322,"link_btn",function() { window.open("http://mlpeg.com","_blank"); },this); Link_Btn.anchor.setTo(0.5,0.5); Link_Btn.scale.setTo(1.4,0.3); Link_Btn.alpha = 0; //Close button at the upper right corner of the Credits_Text /*We add it as a sprite so that we can make it zoom in and zoom out by scaling it when the user click the close button*/ Close_Btn = this.add.button(0,0,"close_btn",function() { //we make the Credits_Group invisible and the Credits_Btn visible again Credits_Group.visible = false; Credits_Btn.visible = true; //enable all buttons that is meant to be clickable when Credits is closed Play_Btn.inputEnabled = true; },this,1,0,2); Close_Btn.anchor.setTo(0.5,0.5); Close_Btn.x = 876; Close_Btn.y = 91; //Group that will hold all the graphics that we need for the credits screen Credits_Group = this.add.group(); Credits_Group.add(Screen_Effect); Credits_Group.add(Credits_Text); Credits_Group.add(Link_Btn); Credits_Group.add(Close_Btn); //we make it initially invisible to hide it from the users view Credits_Group.visible = false; //sound button SoundBtn = this.add.button(46,42,"sound_btn", function() { if(!MuteBool) { SoundBtn.animations.play("soundOff"); this.sound.mute = true; MuteBool = true; } else if(MuteBool) { SoundBtn.animations.play("soundOn"); this.sound.mute = false; MuteBool = false; } },this); SoundBtn.anchor.setTo(0.5,0.5); SoundBtn.animations.add("soundOn",[0],1,false); SoundBtn.animations.add("soundOff",[1],1,false); PosTextBool = false; /*PosTextBool = true; PosText = this.add.text(870,110,"Hello",{font:"40px Arial",fill:"#ffffff"}); PosText.anchor.setTo(0.5,0.5); PosText.setShadow(3,3,"rgba(0,0,0,0.5)",2); debug_fnc(PosText);*/ }, update: function() { //this.state.start("DressUp"); if(gamepaused) { if(MuteBool) { SoundBtn.animations.play("soundOn"); this.sound.mute = false; MuteBool = false; } if(!MuteBool) { SoundBtn.animations.play("soundOff"); this.sound.mute = true; MuteBool = true; } } }, } function debug_fnc(Obj) { /*this.input.onDown.add(function() { Obj.animations.play("Tool8Anim"); },this);*/ Obj.inputEnabled = true; Obj.input.enableDrag(false); Obj.events.onInputUp.add(function() { if(PosTextBool){PosText.text = Obj.x + "\n" + Obj.y;} else{console.log(Obj.x + "\n" + Obj.y);} },this); }