1Juego.Cangrejos=function(game){}; 2Juego.Cangrejos.prototype={ 3 create: function(){ 4 this.game.stage.backgroundColor = '#0a38a0'; 5 var myBitmap = this.game.add.bitmapData(Juego._WIDTH, Juego._HEIGHT); 6 var grd=myBitmap.context.createLinearGradient(0,0,0,Juego._HEIGHT); 7 grd.addColorStop(0,"#816647"); 8 grd.addColorStop(1,"#d9bb7a"); 9 myBitmap.context.fillStyle=grd; 10 myBitmap.context.fillRect(0,80,Juego._WIDTH,Juego._HEIGHT); 11 this.game.add.sprite(0, 0, myBitmap); 12 13 //botones de sonido y volver 14 var imgSonido=this.game.sound.mute?"botonSonidoNo.png":"botonSonido.png"; 15 this.audioButton=this.game.add.sprite(Juego._WIDTH-140, 4, "imgUI", imgSonido); 16 this.audioButton.inputEnabled = true; 17 this.audioButton.events.onInputDown.add(Juego.manageAudio, this); 18 this.audioButton.input.useHandCursor = true; 19 this.volverButton= this.add.button(Juego._WIDTH-70, 4, "imgUI", this.volverMenu, this, "botonVolver.png", "botonVolver.png", "botonVolver.png"); 20 this.volverButton.input.useHandCursor=true; 21 22 this.definir(); 23 24 this.maxCangrejos=5 25 this.cangrejos=this.game.add.group(); 26 var fuente={ font: "42px Arial", align: "center", fill: "#FFFFFF" }; 27 for(var n=0; n<this.maxCangrejos; n++){ 28 c=this.cangrejos.create(-Math.floor(Math.random()*300), 80+n*150, "imgAnimales"); 29 c.animations.add('anda', ["Crab.png", "crab2.png", "crab3.png"], 10, true); 30 c.animations.play("anda"); 31 32 cuadro=this.game.add.sprite(17, -57, "cuadro"); 33 c.addChild(cuadro); 34 35 c.t=this.game.add.text(cuadro.width*.5+13,cuadro.y+5,2 + Math.floor(Math.random()*8), fuente); 36 c.t.anchor.set(.5,0); 37 c.addChild(c.t); 38 39 c.inputEnabled = true; 40 c.events.onInputDown.add(this.alPulsar, this); 41 } 42 43 var fuenteGrandeNegra={ font: "bold 60px Arial", align: "center", fill: "#0" }; 44 this.txtOperacion=this.game.add.text(Juego._WIDTH*.5, Juego._HEIGHT-150, "6+3", fuenteGrandeNegra); 45 this.txtOperacion.anchor.set(.5,0); 46 47 this.muyBien=new MuyBien(this.game, this); 48 this.panel=new Panel(this.game, "¡Muy Bien!", "30", this.iniPartida, this.volverMenu, this); 49 50 this.sndAciertoMini=this.game.add.audio("aciertoMini"); 51 this.sndAcierto=this.game.add.audio("acierto"); 52 this.sndFallo=this.game.add.audio("fallo"); 53 54 this.iniPartida(); 55 }, 56 57 update: function(){ 58 if(this.enMarcha) 59 this.cangrejos.forEach(function(obj){obj.x += 2; if(obj.x>Juego._WIDTH) obj.x=-Math.floor(Math.random()*200)}); 60 }, 61 62 iniPartida: function(){ 63 this.enMarcha=true; 64 this.fase=0; 65 this.errores=0; 66 this.iniFase(); 67 }, 68 69 iniFase: function(){ 70 this.fase++; 71 if(this.fase<11){ 72 //Juego.op=["+", "-"]; //indica el tipo de operación y lo pasan desde MainMenu.js 73 Juego.op=(Juego.op||"+"); 74 this.op1=Math.floor(Math.random()*9)+2; 75 this.op2=Math.floor(Math.random()*8)+3; 76 if(Juego.op=="-" && this.op2>this.op1){ //si estamos restando, me aseguro de que el primer operando sea mayor 77 var aux=this.op1; 78 this.op1=this.op2; 79 this.op2=aux; 80 } 81 if(Juego.op=="+"){ 82 this.solucion=this.op1+this.op2; 83 }else{ 84 this.solucion=this.op1-this.op2 85 } 86 87 this.cangrejos.forEach(function(obj){obj.t.text=Math.abs(this.solucion+(4-Math.floor(Math.random()*8)))}, this); 88 89 var auxPosSolucion=Math.floor(Math.random()*this.maxCangrejos); 90 this.cangrejos.children[auxPosSolucion].t.text=this.solucion; 91 92 this.txtOperacion.text=this.op1 + " " + Juego.op + " " + this.op2; 93 }else{ 94 this.sndAcierto.play(); 95 this.enMarcha=false; 96 Juego.mascota.masEstrellas(30); 97 Juego.mascota.cambiarIndice(20, "conocimiento", "matematicas");
98 this.panel.mostrarPanel("¡Muy Bien!", 30, false, this.iniPartida, this.volverMenu, Juego.numEstrellas(11-this.errores, 8)); 99 //this.panel.mostrarPanel("¡Muy bien!", 30); 100 } 101 }, 102 103 alPulsar: function(item){ 104 if(this.enMarcha && item.t.text==this.solucion){ 105 this.sndAciertoMini.play(); 106 this.muyBien.mostrar(); 107 }else{ 108 this.sndFallo.play(); 109 if(this.enMarcha) this.errores++; 110 } 111 }, 112 113 definir: function(){ 114 var frame0 = [ 115 '888888888888888', 116 '877777777777778', 117 '877444444444778', 118 '874444444444478', 119 '874444444444478', 120 '874444444444478', 121 '874444444444478', 122 '874444444444478', 123 '874444444444478', 124 '874444444444478', 125 '874444444444478', 126 '874444444444478', 127 '877444444444778', 128 '877777777777778', 129 '888888888888888' 130 ]; 131 this.game.create.texture('cuadro', frame0, 4, 4, 0); 132 }, 133 134 volverMenu: function(){ 135 Juego.mascota.guardarResultados(); 136 this.game.state.start("MainMenu"); 137 } 138}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.