/* var menuSquareTwo = { create: function(){}, ---------------------------- end of phaser functions loadMap: function(){} }; var mapSquareTwo = { create: function(){}, update: function(){}, ---------------------------- end of phaser functions loadGame: function() }; var gameSquareTwo = { create: function(){}, update: function(){}, ---------------------------- end of phaser functions updateCounter: function(){}, overSquare: function(){}, outSquare: function(){}, clickSquare: function(){}, //setPlace: function(){}, postScore: function(){}, //viewHelp: function(){}, //checkOverlap: function(){} getRndDivisor: function(){} }; var endSquareTwo = { create: function(){}, update: function(){}, ---------------------------- end of phaser functions verPrincipal: function(){}, verMenu: function(){} }; } */ // Fractions Comparison Square states /****************************** MENU ****************************/ var menuSquareTwo = { create: function() { // Creating sound variable var beepSound = game.add.audio('sound_beep'); // Menu options buttonSettings["addButtons"](1,1, 0,1,0, 1,0, 0,0); // Setting title var style = { font: '28px Arial', fill: '#00804d'}; var title = game.add.text(game.world.centerX, 40, lang.game_menu_title, style); title.anchor.setTo(0.5, 0.5); //Showing Games and Levels var maxHeight = 120; //Max height of a stair var stairHeight = 29; //height growth of a stair var stairWidth = 80; //Width of a stair var startStair = 240; var startSymbol = 150; var startSquare = (startSymbol/2)+startStair+stairWidth*5; var bplus = game.add.sprite(startSymbol, 300, 'equal'); bplus.frame = 0; bplus.scale.setTo(0.7); bplus.anchor.setTo(0.5,0.5); //First stairs, 6 levels var stairsA = []; for(var i=1;i<=5;i++){ //stair var x1 = startStair+(stairWidth*(i-1)); var y1 = 100+maxHeight-i*stairHeight; var x2 = stairWidth;//x1 + 40; var y2 = stairHeight*i;//y1 + 24; stairsA[i] = game.add.graphics(0, 0); stairsA[i].lineStyle(1, 0xFFFFFF, 1); stairsA[i].beginFill(0x99b3ff); stairsA[i].drawRect(x1, y1, x2, y2); stairsA[i].endFill(); //event stairsA[i].inputEnabled = true; stairsA[i].input.useHandCursor = true; stairsA[i].events.onInputDown.add(this.loadMap, {beep: beepSound, difficulty: i, type: 'A' }); stairsA[i].events.onInputOver.add(function (item) { item.alpha=0.5; }, this); stairsA[i].events.onInputOut.add(function (item) { item.alpha=1; }, this); //label var xl = x1+stairWidth/2; //x label var yl = y1+(stairHeight*i)/2; //y label var label = game.add.text(xl, yl, i, { font: '25px Arial', fill: '#ffffff', align: 'center' }); label.anchor.setTo(0.5, 0.4); } //second stairs var stairsB = []; for(var i=1;i<=5;i++){ //stair var x1 = startStair+(stairWidth*(i-1)); var y1 = 270+maxHeight-i*stairHeight; var x2 = stairWidth;//x1 + 40; var y2 = stairHeight*i;//y1 + 24; stairsB[i] = game.add.graphics(0, 0); stairsB[i].lineStyle(1, 0xFFFFFF, 1); stairsB[i].beginFill(0xff6666); stairsB[i].drawRect(x1, y1, x2, y2); stairsB[i].endFill(); //event stairsB[i].inputEnabled = true; stairsB[i].input.useHandCursor = true; stairsB[i].events.onInputDown.add(this.loadMap, {beep: beepSound, difficulty: i, type: 'B' }); stairsB[i].events.onInputOver.add(function (item) { item.alpha=0.5; }, this); stairsB[i].events.onInputOut.add(function (item) { item.alpha=1; }, this); //label var xl = x1+stairWidth/2; //x label var yl = y1+(stairHeight*i)/2; //y label var label = game.add.text(xl, yl, i, { font: '25px Arial', fill: '#ffffff', align: 'center' }); label.anchor.setTo(0.5, 0.4); } //third stair var stairsC = []; for(var i=1;i<=5;i++){ //stair var x1 = startStair+(stairWidth*(i-1)); var y1 = 440+maxHeight-i*stairHeight; var x2 = stairWidth;//x1 + 40; var y2 = stairHeight*i;//y1 + 24; stairsC[i] = game.add.graphics(0, 0); stairsC[i].lineStyle(1, 0xFFFFFF, 1); stairsC[i].beginFill(0xb366ff); stairsC[i].drawRect(x1, y1, x2, y2); stairsC[i].endFill(); //event stairsC[i].inputEnabled = true; stairsC[i].input.useHandCursor = true; stairsC[i].events.onInputDown.add(this.loadMap, {beep: beepSound, difficulty: i, type: 'C' }); stairsC[i].events.onInputOver.add(function (item) { item.alpha=0.5; }, this); stairsC[i].events.onInputOut.add(function (item) { item.alpha=1; }, this); //label var xl = x1+stairWidth/2; //x label var yl = y1+(stairHeight*i)/2; //y label var label = game.add.text(xl, yl, i, { font: '25px Arial', fill: '#ffffff', align: 'center' }); label.anchor.setTo(0.5, 0.4); } }, //MapLoading function loadMap: function(){ if(audioStatus){ this.beep.play(); } twoPosition = 0; //Map position twoMove = true; //Move no next point twoDifficulty = this.difficulty; //Number of difficulty (1 to 5) twoType = this.type; //Operator of game if(twoPosition<5){ game.state.start('mapSTwo'); }else{ game.state.start('unofinal'); } }, }; /****************************** MAP ****************************/ var mapSquareTwo={ create: function() { // Creating sound variable beepSound = game.add.audio('sound_beep'); // Background game.add.image(0, 40, 'bgmap'); // Menu options buttonSettings["addButtons"](1,0, 1,1,0, 0,0, "menuSTwo",0); // Styles for labels var stylePlace = { font: '26px Arial', fill: '#ffffff', align: 'center'}; var styleMenu = { font: '30px Arial', fill: '#000000', align: 'center'}; // Progress bar var percentText = onePosition*20; var percentBlocks = onePosition; for(var p=1;p<=percentBlocks;p++){ var block = game.add.image(680+(p-1)*30, 10, 'block'); block.scale.setTo(2, 1); //Scaling to double width } game.add.text(840, 10, percentText+'%', styleMenu); game.add.text(670, 10, lang.difficulty + ' ' + oneDifficulty, styleMenu).anchor.setTo(1,0); game.add.image(680, 10, 'pgbar'); //Road this.points = { 'x': [ 90, 204, 318, 432, 546, 660 ], 'y': [ 486, 422, 358, 294, 230, 166 ] }; //House var house = game.add.image(this.points.x[0], this.points.y[0], 'house'); house.scale.setTo(0.7); house.anchor.setTo(0.7, 0.8); //School var school = game.add.image(this.points.x[5], this.points.y[5], 'school'); school.scale.setTo(0.35); school.anchor.setTo(0.2, 0.7); //Trees and Rocks this.rocks = { 'x': [156, 275, 276, 441, 452, 590, 712], 'y': [309, 543, 259, 156, 419, 136, 316] } this.r_types = [1, 1, 2, 1, 2, 2, 2]; for(var i=0; i0 && p=800){ kidDirection='left'; kid.animations.play('left', 8, true); } }else{ kid.x -= 1; if(kid.x<=100){ kidDirection='right'; kid.animations.play('right', 8, true); } } } //If clicked A only, animate if(animateA){ for(var i=0;i=auxblqA.children[0].y){ animateA = false; fractionA.alpha = 1; fractionA.setText(valueA+"\n"+sizeA); separatorA.alpha = 1; } } //If clicked B only, animate if(animateB){ for(var i=0;i=auxblqB.children[0].y){ animateB = false; fractionB.alpha = 1; fractionB.setText(valueB+"\n"+sizeB); separatorB.alpha = 1; } } //if clicked A and B if(clickA && clickB && !this.animate){ //Check result timer.stop(); cDelay++; if(cDelay>=eDelay){ //fractions are equivalent : correct if((valueA/sizeA) == (valueB/sizeB)){ result = true; twoMove = true; if(audioStatus){ okSound.play(); } okImg.alpha = 1; //fractions are not equivalent }else{ result = false; twoMove = false; if(audioStatus){ errorSound.play(); } kid.animations.stop(); errorImg.alpha = 1; } this.postScore(); clickA = false; clickB = false; animate = true; } } if(animate){ counter++; if(result){ kid.x += 2; kidDirection='right'; kid.animations.play('right', 8, true); } if(counter>endCounter){ game.state.start('mapSTwo'); } } }, updateCounter: function() { totalTime++; }, overSquare: function(){ if(!clickA && this.who=="A"){ if(this.indice == sizeA-1){ if(yA==90){ errorTextA.setText(lang.error_msg); errorTextB.setText(""); }else{ errorTextA.setText(""); errorTextB.setText(lang.error_msg); } }else{ errorTextA.setText(""); errorTextB.setText(""); for(var i=0;i