logical error


hi , how ?

i made game in 1 stage , works  without errors have problem , here pictures insert code

 

 

first there 1 hero, , enemy .and 1 portal 

when touch enemy it  hit , gonna lose hp until death 

like here

 

[url=http://www.gulfup.com/show/x9e9628ecxzc4cw][img]http://im18.gulfup.com/2012-08-11/1344659217691.png[/img][/url]

 

 

but there portal can use kill enemy (the pat )

here

[url=http://www.gulfup.com/show/xs6ria103sf4gw][img]http://im18.gulfup.com/2012-08-11/1344659218552.png[/img][/url]

 

but problem : enemy still hitting ?? dont know why ? remove , events

but it,s still in stage ??

 

here code  of main class , placein document file

[url=http://www.gulfup.com/show/x9e9od31np68sgg][img]http://im17.gulfup.com/2012-08-11/1344660833131.png[/img][/url]

 

 

 

package  {

import flash.display.movieclip;
import flash.events.event;


public class main extends movieclip {
 
 
 
  public function main() {
addeventlistener(event.added_to_stage,onaddedtostage)  
}


public function onaddedtostage(event:event):void
  {
addeventlistener(event.enter_frame,onenterframe )
  addeventlistener(event.removed_from_stage,onremovedfromstage)
 
}


private function onremovedfromstage(event:event):void
  {
   removeeventlistener(event.enter_frame, onenterframe);
   removeeventlistener(event.added_to_stage, onaddedtostage);
   removeeventlistener(event.removed_from_stage, onremovedfromstage);
   trace("player removed");
  }
  public function onenterframe (event:event)
  {
  
    if (hero.hittestobject(bat1))
    {
     healthbar1.width -=1
    
    }
    if (healthbar1.width >=  80 && healthbar1.width <=  100 ){
     zelda1.gotoandplay(1)
    }
    if (healthbar1.width >=  60 && healthbar1.width <=  80){
     zelda1.gotoandplay(2)
    }
    if (healthbar1.width >=  40 && healthbar1.width <=  60){
     zelda1.gotoandplay(3)
    }
    if (healthbar1.width >=  20 && healthbar1.width <=  40){
     zelda1.gotoandplay(4)
    }
    if (healthbar1.width >=  0 && healthbar1.width <=  20){
     zelda1.gotoandplay(5)
    }
    if (hero.hittestobject(portal2)){
     var map2:map2 = new map2
     addchild(map2)
     if(map1.stage){
     removechild(map1)
     }
     }
     if (hero.hittestobject(portal3)){
      var map4:background = new background
      if(bat1.stage){
     removechild(bat1)
     bat1.removeeventlistener(event.enter_frame, onenterframe);
     }
     }
  }


}


}

 

and here bat class

 

[url=http://www.gulfup.com/show/x34r84djied4w0s][img]http://im17.gulfup.com/2012-08-11/1344660833422.png[/img][/url]

 

 

 

package  {

 

import flash.display.movieclip;

import flash.events.event;

 

public class bat1 extends movieclip {

 

 

  public function bat1() {

   addeventlistener(event.added_to_stage,onaddedtostage)

  }

  public function onaddedtostage(event:event):void

  {

addeventlistener(event.enter_frame,onenterframe )

  addeventlistener(event.removed_from_stage,onremovedfromstage)

 

}

private function onremovedfromstage(event:event):void

  {

   removeeventlistener(event.enter_frame, onenterframe);

   removeeventlistener(event.added_to_stage, onaddedtostage);

   removeeventlistener(event.removed_from_stage, onremovedfromstage);

   trace("bat removed");

  }

  public function onenterframe (event:event)

  {

  

  }

 

}

 

}

 

 

thats , iam sure that(the pat has removed because saw in trace message)

bat1 removed

 

here

[url=http://www.gulfup.com/show/x9e9w762dv5cs4k][img]http://im18.gulfup.com/2012-08-11/1344661317721.png[/img][/url]

 

thank you

 

(yeah right images dont work auto dont know why , can click work )

thanks again)

you don't have trace("bat1 removed") in code.



More discussions in ActionScript 3


adobe

Comments

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

After Effect warning: A problem occurred when processing OpenGL commands

Preconditions Failed. - Joomla! Forum - community, help and support