Instead of adding a constant 10, you can have a variable, and change that variable value.
You should also consider keeping int variables for all your numbers rather than using the text values in the textfields.
You should also consider using a Timer rather than setInterval/clearInterval.Code:var dropSpeed:Number = 10; var atrapadasNum:int = 0; var erradasNum:int = 0; function crearID():void{ var enemigo:Cayendo=new Cayendo() enemigo.y=-50; enemigo.x=Math.random()*stage.stageWidth; enemigo.addEventListener(Event.ENTER_FRAME,dropEnemy); addChild(enemigo); } function dropEnemy(e:Event):void{ var mc:Cayendo=Cayendo(e.target); mc.y+=dropSpeed; if(mc.hitTestObject(agarrador)){ atrapadas(mc); }else if(mc.y>stage.stageHeight){ erradas(mc); } } function atrapadas(mc:Cayendo):void{ mc.removeEventListener(Event.ENTER_FRAME,dropEnemy); removeChild(mc); atrapadasNum++; atrapadasText.text=String(atrapadasNum); if(atrapadasNum == 50){ dropSpeed = 60; nivel2.gotoAndPlay(1); } } function erradas(mc:Cayendo):void{ mc.removeEventListener(Event.ENTER_FRAME,dropEnemy); removeChild(mc); erradasNum++; erradasText.text=String(erradasNum); if(erradasNum == 5){ gameOver(); } } function gameOver():void{ score=atrapadasNum; removeChild(agarrador); clearInterval(crearIDenemigo); removeChild(atrapadasText); removeChild(erradasText); while(numChildren>0){ getChildAt(0).removeEventListener(Event.ENTER_FRAME,dropEnemy); removeChildAt(0); } stage.removeEventListener(KeyboardEvent.KEY_DOWN, presionoTecla); stage.removeEventListener(KeyboardEvent.KEY_UP, sueltoTecla); stage.removeEventListener(Event.ENTER_FRAME , mover); gotoAndStop("game over"); Mouse.show(); } iniciarJuego();




Reply With Quote
