0 Replies Latest reply on May 3, 2006 6:54 AM by michael novia

    eval and hittest

    michael novia
      http://www.armyvisual.com/nova

      here's the link to the .swf so you can experience the problem. Shooting the 'pellets' or cirlces, you notice its extrmely innacurrate, it goes through them a bunch, then will pop them all at once, and visa versa.

      I am not much of a programmer, so im having lots of issues with the hitTest.

      I will post up the code that creates my enemys and bullets its where i belive the erronous code is, as well as the code that checks the collisions. If you wouldnt mind helping, that would be great- thank you so much.

      ----------------------------------------------------------

      //SHOOT!
      if (Key.isDown(Key.SPACE) && bulletCount>0) {
      //FIRE BULLETS!
      attachMovie("bullet", "bullet"+bulletNum, bulletNum);
      eval("_root.bullet"+bulletNum)._x = _root.ship._x+ship._width/2;
      eval("_root.bullet"+bulletNum)._y = _root.ship._y;
      ++bulletNum;
      --bulletCount;
      if (bulletNum>9) {
      bulletNum = 0;
      }
      }
      -----------------------------------------------------------
      //NEW ENEMY
      function addEnemy() {
      attachMovie("res", "enemy"+enemyNum, enemyNum*600);
      eval("_root.enemy"+enemyNum)._x = 10+enemyNum*25;
      eval("_root.enemy"+enemyNum)._y = 100+enemyNum;
      trace(enemyNum);
      ++enemyNum;
      if (enemyNum>10) {
      enemyNum = 0;
      }
      }
      ----------------------------------------------------------

      //BULLET COLLISION
      var bulleti = 100;
      while (--bulleti>0) {
      if (_root.tWall.hitTest(eval("_root.bullet"+bulleti))) {
      unloadMovie(eval("_root.bullet"+bulleti));
      bulletExplode(eval("_root.bullet"+bulleti)._x, eval ("_root.bullet"+bulleti)._y);
      }
      }

      -----------------------------------------------------------
      //ENEMY COLLISION
      var enemyi = 11;
      while (--enemyi>0) {
      if (eval("_root.enemy"+enemyi).hitTest(eval("_root.bullet"+bulleti))) {
      throwScore();
      enemyDie(eval("_root.bullet"+bulleti)._x, eval("_root.bullet"+bulleti)._y);
      addEnemy();
      addEnemy();
      unloadMovie(eval("_root.enemy"+enemyi));
      }
      }

      ------------------------------------------------------------

      thank you so much guys, this project needs to be shown to the client tommorow.