OwlCyberSecurity - MANAGER
Edit File: titlescreen.js
var titleScreen = function(game) { MuteBool = false; gamepaused = false; GameTitle = "star_vs_evil_avatar_maker"; } var initialized = false; var initGDApi = function(){ if(!initialized){ // Api will be initialized once, so preroll is shown once either var settings = { gameId: "ed3e453e46694da89a3156e64edf9f2e", 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,0,"background"); //Ref = this.add.image(0,0,"ref"); //Doll Intro_Character = this.add.sprite(332,689,"intro_character"); Intro_Character.anchor.setTo(0.5,0.5); //Intro_Character.smoothed = false; //add the title of the game Title = this.add.image(823,253,"title"); Title.anchor.setTo(0.5,0.5); GP_Btn = this.add.button(330,569,"gp_btn",function() { window.open("https://play.google.com/store/apps/details?id=air.com.kawaiigames.starvsevilavatarmaker","_blank"); },this); GP_Btn.anchor.setTo(0.5,0.5); //add the Play Button sprite Play_Btn = this.add.button(819,571,"play_btn",function() { initGDApi(); this.state.start("DressUp"); },this,1,0,2); Play_Btn.anchor.setTo(0.5,0.5); Logo = this.add.button(82,508,"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.scale.setTo(1.3,1.3); Logo.smoothed = false; Credits_Btn = this.add.button(75,605,"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 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(688,310,"link_btn",function() { window.open("http://disneyxd.com","_blank"); },this); Link_Btn.anchor.setTo(0.5,0.5); Link_Btn.scale.setTo(3,0.3); Link_Btn.alpha = 0; Link_Btn2 = this.add.button(622,368,"link_btn",function() { window.open("https://www.youtube.com/watch?v=o-IyvK4lAuk","_blank"); },this); Link_Btn2.anchor.setTo(0.5,0.5); Link_Btn2.scale.setTo(6,0.9); Link_Btn2.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(Credits_Text.x + Credits_Text.width/2 - 35,Credits_Text.y - Credits_Text.height/2 + 35,"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); //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(Link_Btn2); 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.sound.mute = true; //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); }