/* var menuSquareTwo = { create: function(){}, ---------------------------- end of phaser functions func_loadMap: function(){} }; var mapSquareTwo = { create: function(){}, update: function(){}, ---------------------------- end of phaser functions loadGame: function() }; var gameSquareTwo = { create: function(){}, update: function(){}, ---------------------------- end of phaser functions func_updateCounter: function(){}, func_overSquare: function(){}, func_outSquare: function(){}, func_clickSquare: function(){}, //func_setPlace: function(){}, func_postScore: function(){}, //func_viewHelp: function(){}, //func_checkOverlap: function(){} func_getRndDivisor: function(){} }; var endSquareTwo = { create: function(){}, update: function(){}, ---------------------------- end of phaser functions func_verPrincipal: function(){}, }; */ // Fractions Comparison Square states /****************************** MENU ****************************/ var menuSquareTwo = { create: function() { // Navigation buttons buttonSettings["func_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); //SETTING DIFFICULTY 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 equalsIcon = game.add.sprite(startSymbol, 300, 'equal'); equalsIcon.frame = 0; equalsIcon.scale.setTo(0.7); equalsIcon.anchor.setTo(0.5,0.5); //First stairs, More divisions to less divisions 1, 5 levels var stairsMoreToLess1 = []; 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; stairsMoreToLess1[i] = game.add.graphics(0, 0); stairsMoreToLess1[i].lineStyle(1, 0xFFFFFF, 1); stairsMoreToLess1[i].beginFill(0x99b3ff); stairsMoreToLess1[i].drawRect(x1, y1, x2, y2); stairsMoreToLess1[i].endFill(); //event stairsMoreToLess1[i].inputEnabled = true; stairsMoreToLess1[i].input.useHandCursor = true; stairsMoreToLess1[i].events.onInputDown.add(this.func_loadMap, {beep: beepSound, difficulty: i, type: 'A' }); stairsMoreToLess1[i].events.onInputOver.add(function (item) { item.alpha=0.5; }, this); stairsMoreToLess1[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, More divisions to less divisions 2, 5 levels var stairsMoreToLess2 = []; 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; stairsMoreToLess2[i] = game.add.graphics(0, 0); stairsMoreToLess2[i].lineStyle(1, 0xFFFFFF, 1); stairsMoreToLess2[i].beginFill(0xff6666); stairsMoreToLess2[i].drawRect(x1, y1, x2, y2); stairsMoreToLess2[i].endFill(); //event stairsMoreToLess2[i].inputEnabled = true; stairsMoreToLess2[i].input.useHandCursor = true; stairsMoreToLess2[i].events.onInputDown.add(this.func_loadMap, {beep: beepSound, difficulty: i, type: 'B' }); stairsMoreToLess2[i].events.onInputOver.add(function (item) { item.alpha=0.5; }, this); stairsMoreToLess2[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 stairs, Less divisions to more divisions, 5 levels var stairsLessToMore = []; 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; stairsLessToMore[i] = game.add.graphics(0, 0); stairsLessToMore[i].lineStyle(1, 0xFFFFFF, 1); stairsLessToMore[i].beginFill(0xb366ff); stairsLessToMore[i].drawRect(x1, y1, x2, y2); stairsLessToMore[i].endFill(); //event stairsLessToMore[i].inputEnabled = true; stairsLessToMore[i].input.useHandCursor = true; stairsLessToMore[i].events.onInputDown.add(this.func_loadMap, {beep: beepSound, difficulty: i, type: 'C' }); stairsLessToMore[i].events.onInputOver.add(function (item) { item.alpha=0.5; }, this); stairsLessToMore[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 func_loadMap: function(){ if(audioStatus){ this.beep.play(); } levelPosition = 0; //Map position levelMove = true; //Move no next point levelDifficulty = this.difficulty; //Number of difficulty (1 to 5) levelType = this.type; //Type of game passedLevels = 0; game.state.start('mapSTwo'); }, }; /****************************** MAP ****************************/ var mapSquareTwo={ create: function() { // Background game.add.image(0, 40, 'bgmap'); // Navigation buttons buttonSettings["func_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 = passedLevels*25; var percentBlocks = passedLevels; for(var p=0;p0 && p 20 ){ var xPos = game.input.mousePointer.x; /*if (xPos < kid.x + 10){ kidDirection='right'; kid.animations.play('right', 8, true); }else if (xPos > kid.x){ kidDirection='right'; kid.animations.play('right', 8, true); }*/ //set limit to the arrow if (xPos < kidLeftLimit){ xPos = kidLeftLimit; } if (xPos > kidRightLimit){ xPos = kidRightLimit; } kid.x = xPos; } //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; levelMove = true; if(audioStatus){ okSound.play(); } kid.animations.stop(); passedLevels++; if(debugMode) console.log("passedLevels = " + passedLevels); okImg.alpha = 1; //fractions are not equivalent }else{ result = false; levelMove = false; if(audioStatus){ errorSound.play(); } kid.animations.stop(); errorImg.alpha = 1; } this.func_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'); } } }, func_updateCounter: function() { totalTime++; }, func_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