Browse Source

made buttons mode responsive to user | fixed bug on last commit where the button would return to wrong level

lairaalmas 5 years ago
parent
commit
f3382a1b67
3 changed files with 43 additions and 27 deletions
  1. 24 18
      js/menu.js
  2. 18 8
      js/preMenu.js
  3. 1 1
      js/squareTwo.js

+ 24 - 18
js/menu.js

@@ -60,64 +60,64 @@ var menuState = {
         menu1.inputEnabled = true;
         menu1.inputEnabled = true;
         menu1.input.useHandCursor = true;
         menu1.input.useHandCursor = true;
         menu1.events.onInputDown.add(this.loadGame,{num:1, beep: beepSound, shape : "Circle", label : true});
         menu1.events.onInputDown.add(this.loadGame,{num:1, beep: beepSound, shape : "Circle", label : true});
-        menu1.events.onInputOver.add(this.showTitle,{num:1, beep: beepSound, shape : "Circle", label : true});
-        menu1.events.onInputOut.add(this.clearTitle);
+        menu1.events.onInputOver.add(this.showTitle,{num:1, beep: beepSound, shape : "Circle", label : true, menu: menu1});
+        menu1.events.onInputOut.add(this.clearTitle, {menu: menu1});
         
         
         menu2.anchor.setTo(0.5, 0.5);
         menu2.anchor.setTo(0.5, 0.5);
         menu2.inputEnabled = true;
         menu2.inputEnabled = true;
         menu2.input.useHandCursor = true;
         menu2.input.useHandCursor = true;
         menu2.events.onInputDown.add(this.loadGame,{num:2, beep: beepSound, shape : "Circle", label : false});
         menu2.events.onInputDown.add(this.loadGame,{num:2, beep: beepSound, shape : "Circle", label : false});
-        menu2.events.onInputOver.add(this.showTitle,{num:2, beep: beepSound, shape : "Circle", label : false});
-        menu2.events.onInputOut.add(this.clearTitle);
+        menu2.events.onInputOver.add(this.showTitle,{num:2, beep: beepSound, shape : "Circle", label : false, menu: menu2});
+        menu2.events.onInputOut.add(this.clearTitle, {menu: menu2});
         
         
         menu3.anchor.setTo(0.5, 0.5);
         menu3.anchor.setTo(0.5, 0.5);
         menu3.inputEnabled = true;
         menu3.inputEnabled = true;
         menu3.input.useHandCursor = true;
         menu3.input.useHandCursor = true;
         menu3.events.onInputDown.add(this.loadGame,{num:3, beep: beepSound, shape : "Circle", label : true});
         menu3.events.onInputDown.add(this.loadGame,{num:3, beep: beepSound, shape : "Circle", label : true});
-        menu3.events.onInputOver.add(this.showTitle,{num:3, beep: beepSound, shape : "Circle", label : true});
-        menu3.events.onInputOut.add(this.clearTitle);
+        menu3.events.onInputOver.add(this.showTitle,{num:3, beep: beepSound, shape : "Circle", label : true, menu: menu3});
+        menu3.events.onInputOut.add(this.clearTitle, {menu: menu3});
         
         
         menu4.anchor.setTo(0.5, 0.5);
         menu4.anchor.setTo(0.5, 0.5);
         menu4.inputEnabled = true;
         menu4.inputEnabled = true;
         menu4.input.useHandCursor = true;
         menu4.input.useHandCursor = true;
         menu4.events.onInputDown.add(this.loadGame,{num:4, beep: beepSound, shape : "Circle", label : false});
         menu4.events.onInputDown.add(this.loadGame,{num:4, beep: beepSound, shape : "Circle", label : false});
-        menu4.events.onInputOver.add(this.showTitle,{num:4, beep: beepSound, shape : "Circle", label : false});
-        menu4.events.onInputOut.add(this.clearTitle);
+        menu4.events.onInputOver.add(this.showTitle,{num:4, beep: beepSound, shape : "Circle", label : false, menu: menu4});
+        menu4.events.onInputOut.add(this.clearTitle, {menu: menu4});
         
         
         menu5.anchor.setTo(0.5, 0.5);
         menu5.anchor.setTo(0.5, 0.5);
         menu5.inputEnabled = true;
         menu5.inputEnabled = true;
         menu5.input.useHandCursor = true;
         menu5.input.useHandCursor = true;
         menu5.events.onInputDown.add(this.loadGame,{num:1, beep: beepSound, shape : "Square", label : true});
         menu5.events.onInputDown.add(this.loadGame,{num:1, beep: beepSound, shape : "Square", label : true});
-        menu5.events.onInputOver.add(this.showTitle,{num:1, beep: beepSound, shape : "Square", label : true});
-        menu5.events.onInputOut.add(this.clearTitle);
+        menu5.events.onInputOver.add(this.showTitle,{num:1, beep: beepSound, shape : "Square", label : true, menu: menu5});
+        menu5.events.onInputOut.add(this.clearTitle, {menu: menu5});
         
         
         menu6.anchor.setTo(0.5, 0.5);
         menu6.anchor.setTo(0.5, 0.5);
         menu6.inputEnabled = true;
         menu6.inputEnabled = true;
         menu6.input.useHandCursor = true;
         menu6.input.useHandCursor = true;
         menu6.events.onInputDown.add(this.loadGame,{num:2, beep: beepSound, shape : "Square", label : false});
         menu6.events.onInputDown.add(this.loadGame,{num:2, beep: beepSound, shape : "Square", label : false});
-        menu6.events.onInputOver.add(this.showTitle,{num:2, beep: beepSound, shape : "Square", label : false});
-        menu6.events.onInputOut.add(this.clearTitle);
+        menu6.events.onInputOver.add(this.showTitle,{num:2, beep: beepSound, shape : "Square", label : false, menu: menu6});
+        menu6.events.onInputOut.add(this.clearTitle, {menu: menu6});
         
         
         menu7.anchor.setTo(0.5, 0.5);
         menu7.anchor.setTo(0.5, 0.5);
         menu7.inputEnabled = true;
         menu7.inputEnabled = true;
         menu7.input.useHandCursor = true;
         menu7.input.useHandCursor = true;
         menu7.events.onInputDown.add(this.loadGame,{num:3, beep: beepSound, shape : "Square", label : true});
         menu7.events.onInputDown.add(this.loadGame,{num:3, beep: beepSound, shape : "Square", label : true});
-        menu7.events.onInputOver.add(this.showTitle,{num:3, beep: beepSound, shape : "Square", label : true});
-        menu7.events.onInputOut.add(this.clearTitle);
+        menu7.events.onInputOver.add(this.showTitle,{num:3, beep: beepSound, shape : "Square", label : true, menu: menu7});
+        menu7.events.onInputOut.add(this.clearTitle, {menu: menu7});
         
         
         menu8.anchor.setTo(0.5, 0.5);
         menu8.anchor.setTo(0.5, 0.5);
         menu8.inputEnabled = true;
         menu8.inputEnabled = true;
         menu8.input.useHandCursor = true;
         menu8.input.useHandCursor = true;
         menu8.events.onInputDown.add(this.loadGame,{num:4, beep: beepSound, shape : "Square", label : false});
         menu8.events.onInputDown.add(this.loadGame,{num:4, beep: beepSound, shape : "Square", label : false});
-        menu8.events.onInputOver.add(this.showTitle,{num:4, beep: beepSound, shape : "Square", label : false});
-        menu8.events.onInputOut.add(this.clearTitle);
+        menu8.events.onInputOver.add(this.showTitle,{num:4, beep: beepSound, shape : "Square", label : false, menu: menu8});
+        menu8.events.onInputOut.add(this.clearTitle, {menu: menu8});
         
         
         menu9.anchor.setTo(0.5, 0.5);
         menu9.anchor.setTo(0.5, 0.5);
         menu9.inputEnabled = true;
         menu9.inputEnabled = true;
         menu9.input.useHandCursor = true;
         menu9.input.useHandCursor = true;
         menu9.events.onInputDown.add(this.loadGame,{num:5, beep: beepSound, shape : "Square", label : false});
         menu9.events.onInputDown.add(this.loadGame,{num:5, beep: beepSound, shape : "Square", label : false});
-        menu9.events.onInputOver.add(this.showTitle,{num:5, beep: beepSound, shape : "Square", label : false});
-        menu9.events.onInputOut.add(this.clearTitle);
+        menu9.events.onInputOver.add(this.showTitle,{num:5, beep: beepSound, shape : "Square", label : false, menu: menu9});
+        menu9.events.onInputOut.add(this.clearTitle, {menu: menu9});
 
 
         // Floor
         // Floor
         for(var i=0;i<9;i++){
         for(var i=0;i<9;i++){
@@ -201,10 +201,16 @@ var menuState = {
         
         
         lbl_game.text = title;
         lbl_game.text = title;
 
 
+        this.menu.scale.setTo(1.05);
+
     },
     },
 
 
     clearTitle: function(){
     clearTitle: function(){
+        
         lbl_game.text = "";
         lbl_game.text = "";
+        
+        this.menu.scale.setTo(1.0);
+
     }
     }
     
     
 };
 };

+ 18 - 8
js/preMenu.js

@@ -39,38 +39,46 @@ var langState = {
         //pt_BR
         //pt_BR
         var title1 = game.add.text(this.game.world.centerX - 220, this.game.world.centerY - 100, 'FRAÇÕES  ', style);
         var title1 = game.add.text(this.game.world.centerX - 220, this.game.world.centerY - 100, 'FRAÇÕES  ', style);
         title1.anchor.setTo(1, 0.5);
         title1.anchor.setTo(1, 0.5);
-        var flag1 = game.add.sprite(this.game.world.centerX - 220, this.game.world.centerY - 100, 'flag_BR');       
-        flag1.anchor.setTo(0, 0.5);
+        var flag1 = game.add.sprite(this.game.world.centerX - 120, this.game.world.centerY - 100, 'flag_BR');       
+        flag1.anchor.setTo(0.5, 0.5);
         flag1.inputEnabled = true;
         flag1.inputEnabled = true;
         flag1.input.useHandCursor = true;
         flag1.input.useHandCursor = true;
         flag1.events.onInputDown.add(this.setLang,{lang:'pt_BR'});
         flag1.events.onInputDown.add(this.setLang,{lang:'pt_BR'});
+        flag1.events.onInputOver.add(function(){ flag1.scale.setTo(1.05) });
+        flag1.events.onInputOut.add(function(){ flag1.scale.setTo(1) });
 
 
         //es_PE
         //es_PE
         var title2 = game.add.text(this.game.world.centerX + 200, this.game.world.centerY - 100, 'FRACCIONES  ', style);
         var title2 = game.add.text(this.game.world.centerX + 200, this.game.world.centerY - 100, 'FRACCIONES  ', style);
         title2.anchor.setTo(1, 0.5);
         title2.anchor.setTo(1, 0.5);
-        var flag2 = game.add.sprite(this.game.world.centerX + 200, this.game.world.centerY - 100, 'flag_PE');       
-        flag2.anchor.setTo(0, 0.5);
+        var flag2 = game.add.sprite(this.game.world.centerX + 300, this.game.world.centerY - 100, 'flag_PE');       
+        flag2.anchor.setTo(0.5, 0.5);
         flag2.inputEnabled = true;
         flag2.inputEnabled = true;
         flag2.input.useHandCursor = true;
         flag2.input.useHandCursor = true;
         flag2.events.onInputDown.add(this.setLang,{lang:'es_PE'});
         flag2.events.onInputDown.add(this.setLang,{lang:'es_PE'});
+        flag2.events.onInputOver.add(function(){ flag2.scale.setTo(1.05) });
+        flag2.events.onInputOut.add(function(){ flag2.scale.setTo(1) });
 
 
         //en_US
         //en_US
         var title3 = game.add.text(this.game.world.centerX - 220, this.game.world.centerY + 100, 'FRACTIONS  ', style);
         var title3 = game.add.text(this.game.world.centerX - 220, this.game.world.centerY + 100, 'FRACTIONS  ', style);
         title3.anchor.setTo(1, 0.5);
         title3.anchor.setTo(1, 0.5);
-        var flag3 = game.add.sprite(this.game.world.centerX - 220, this.game.world.centerY + 100, 'flag_US');       
-        flag3.anchor.setTo(0, 0.5);
+        var flag3 = game.add.sprite(this.game.world.centerX - 120, this.game.world.centerY + 100, 'flag_US');       
+        flag3.anchor.setTo(0.5, 0.5);
         flag3.inputEnabled = true;
         flag3.inputEnabled = true;
         flag3.input.useHandCursor = true;
         flag3.input.useHandCursor = true;
         flag3.events.onInputDown.add(this.setLang,{lang:'en_US'});
         flag3.events.onInputDown.add(this.setLang,{lang:'en_US'});
+        flag3.events.onInputOver.add(function(){ flag3.scale.setTo(1.05) });
+        flag3.events.onInputOut.add(function(){ flag3.scale.setTo(1) });
 
 
         //fr_FR
         //fr_FR
         var title4 = game.add.text(this.game.world.centerX + 200, this.game.world.centerY + 100, 'FRACTIONS  ', style);
         var title4 = game.add.text(this.game.world.centerX + 200, this.game.world.centerY + 100, 'FRACTIONS  ', style);
         title4.anchor.setTo(1, 0.5);
         title4.anchor.setTo(1, 0.5);
-        var flag4 = game.add.sprite(this.game.world.centerX + 200, this.game.world.centerY + 100, 'flag_FR');       
-        flag4.anchor.setTo(0, 0.5);
+        var flag4 = game.add.sprite(this.game.world.centerX + 300, this.game.world.centerY + 100, 'flag_FR');       
+        flag4.anchor.setTo(0.5, 0.5);
         flag4.inputEnabled = true;
         flag4.inputEnabled = true;
         flag4.input.useHandCursor = true;
         flag4.input.useHandCursor = true;
         flag4.events.onInputDown.add(this.setLang,{lang:'fr_FR'});
         flag4.events.onInputDown.add(this.setLang,{lang:'fr_FR'});
+        flag4.events.onInputOver.add(function(){ flag4.scale.setTo(1.05) });
+        flag4.events.onInputOut.add(function(){ flag4.scale.setTo(1) });
         
         
     },
     },
     
     
@@ -139,6 +147,8 @@ var nameState = {
         btn.inputEnabled = true;
         btn.inputEnabled = true;
         btn.input.useHandCursor = true;
         btn.input.useHandCursor = true;
         btn.events.onInputDown.add(this.nameIsEmpty, null);
         btn.events.onInputDown.add(this.nameIsEmpty, null);
+        btn.events.onInputOver.add(function(){ btn.alpha=0.4 });
+        btn.events.onInputOut.add(function(){ btn.alpha=0.5 });
         
         
         var ready = game.add.text(this.game.world.centerX + 1, this.game.world.centerY + 102, lang.ready, { font: '34px Arial', fill: '#f0f5f5', align: 'center' });
         var ready = game.add.text(this.game.world.centerX + 1, this.game.world.centerY + 102, lang.ready, { font: '34px Arial', fill: '#f0f5f5', align: 'center' });
         ready.anchor.setTo(0.5);
         ready.anchor.setTo(0.5);

+ 1 - 1
js/squareTwo.js

@@ -372,7 +372,7 @@ var gameSquareTwo = {
         buttonSettings["addButtons"](1,1,
         buttonSettings["addButtons"](1,1,
                                     1,1,0,
                                     1,1,0,
                                     1,0,
                                     1,0,
-                                    "menuSOne", 0);
+                                    "menuSTwo", 0);
 
 
         //Clouds
         //Clouds
         game.add.image(300, 100, 'cloud');
         game.add.image(300, 100, 'cloud');