OwlCyberSecurity - MANAGER
Edit File: titlescreen.js
var titleScreen = function(game) { MuteBool = false; gamepaused = false; } var initialized = false; var initGDApi = function(){ if(!initialized){ // Api will be initialized once, so preroll is shown once either var settings = { gameId: "1255e56c6397480880b118ba25144eef", 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.stage.smoothed = false; //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 = 0.5; //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,0,"background"); //Doll Intro_Character = this.add.sprite(271,351,"intro_character"); Intro_Character.anchor.setTo(0.5,0.5); Intro_Character.smoothed = false; //add the title of the game Title = this.add.image(713,237,"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=rosanna_pansino_dress_up&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; //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(Close_Btn); //we make it initially invisible to hide it from the users view Credits_Group.visible = false; //sound button SoundBtn = this.add.button(60,40,"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); }, update: function() { 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; } } }, }