1 Reply Latest reply on Aug 31, 2011 3:18 AM by kglad

    Distant enemies dont appear

    robi90

      i will explain my problem according the 11th enemy (the last enemy in the level). i past here the answers i gave to people fron other forums..:

       

       

      I'm making a platform game, and i have a problem. i am attaching 11 enemys, and my last enemy not appears. the _X of the 11th enemy is 3300.

      I  tried a lot of stuff, and think, I discovered the source of the problem.

      on my hero class i wrote this:

       

      _root._x -= (_root._x + (_x - 275)) / 5;
      

      and when i changed it to this:

       

      _root._x = -_x;
      

      the last enemy appears!

      but i want it to be like first one.

      but it doesnt work

       

       

       

      also, i found that if i placed the hero close to the last enemy, the last enemy appears.

      
      

       

       

      ok, the _root._x refer to the stage and the _x refer to the hero.

      i found that if i remove this code(the gravity in the enemy class):

      _y += grav;
      grav += gravity;
      while(ground.hitTest(_x, _y, true)){
      _y -= gravity;
      grav = 0;
      }
      

      the last enemy appears. (with no gravity ofcourse).

       

      i explained in that if i am doing this code:

      _root._x = -_x;

      the 11th enemy appears (and i dont need to remove the gravity).

      i also saw that when i am writing on the frame(not in onEnterFrame):

      _root._x = 500000;

      all my enemys not appears.

      so.. its got to be something that conacted to the enemy, and root._x and hero _x; it's a very frustrating bug. (: haha

       

      i also found something intresting:

       

      in the hero class, (where i am sets that the _root._x equal to the hero._x) i did this: i did a if statement that if the "space" isdown the root._x equal to the hero._x, and when "controll" isdown the _root._x equal to the 11th enemy._x. so i think i found something useful:

       

      when i am clicking "space" and continue to play and play a second, and after that clicking "controll" the 11th enemy not appears. but, when i am clicking "space" and right after that clicking "controll" i can see the 11th enemy falling down (and removed because i did when the _y of the enemys is bigger then 460 the will be remove but this isnt related).

       

      i tried everything, none work.

      do you think that it could be a problem in the "core" of flash?

       

      please help, thank you ! (:

        • 1. Re: Distant enemies dont appear
          kglad Adobe Community Professional & MVP

          you shouldn't change the _x (or any other) property of your main timeline (_root).  in your hero class you can adjust the _x property.

           

          at what _x of the main timeline do you want your hero to appear (spawn)?  what code are you using in your hero class to assign the heros' _x property now (for heros 1,2,..,10)?