Hi ! I have a game and i'm trying to make changes when a thing happens
I want to do this, when the "caught" flies rise up to "50" increase the value
for the flies falling frame per frame
so I tried this:
(I post the last part of the code because maybe my mistake could be there)
what i'm doing wrong'?Code: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); //THIS IS WHAT I WANT TO CHANGE WHEN atrapadasText.text=="50" mc.y+=10 //ONLY CHANGING mc.y+=10 to mc.y+=60 IS WHAT I WANT if(mc.hitTestObject(agarrador)){ atrapadas(mc); }else if(mc.y>stage.stageHeight){ erradas(mc); /*THIS IS HOW I MEANT TO DO IT if(atrapadasText.text=="50"){ mc.y+=60 }*/ } function atrapadas(mc:Cayendo):void{ mc.removeEventListener(Event.ENTER_FRAME,dropEnemy); removeChild(mc); atrapadasText.text=String(Number(atrapadasText.text)+1); if(atrapadasText.text=="50"){ nivel2.gotoAndPlay(1); } } function erradas(mc:Cayendo):void{ mc.removeEventListener(Event.ENTER_FRAME,dropEnemy); removeChild(mc); erradasText.text=String(Number(erradasText.text)+1); if(erradasText.text=="5"){ gameOver(); } } function gameOver():void{ score=Number(atrapadasText.text); 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
