hI,
I have a problem in my games’s code.
As it is a space game, the user controls a ship and fires bullets.
So, every time you fire a bullet:
if (Key.isDown(Key.SPACE) && okShoot) {
okShoot = false;
var newDepth = depth++;
var name = "bullet_"+newDepth;
var clip = _root.attachMovie("bullet", name, newDepth);
clip._x = ship._x;
clip._y = ship._y;
//(plus rest of the code that enables the bullet to move)
}
its ok for now(this code works well).
But when I need to check if that bullet has collided with a target(wich is random generated each time you change level), i can´t get the bullets name to pass to the colision function(because I may have already fired hundreds of bullets).
I don´t want to use a “FOR LOOP”, because it slows down the game when you have already fired a lot of bullets.
does any one knows a better way for correcting this code?
thanks for reading.