PDA

View Full Version : AS Problems with gettin bullets to work properly



nikonline666@ho
March 19th, 2005, 12:58 PM
Hi
I've been trying to figure out a problem with AS for hours now, and I come here for help. I've got a mouse controlled person who fires circle bullets up towards oncoming enemies. but since i duplicated them, only the first bullet fired works as it is the only one that has the right instance name.
What I mean is :
The bullet is instanced bullet
When it is duplicated to be fired, it changes to bullet1,bullet2 ect etc
The hittest script on the enemies only reconize bullet, and therefore ignores all other shots except the first
is there anyway of making it so it reconises all shots?
your help will be much appreciated

Mythmon
March 19th, 2005, 01:11 PM
the only way that i know of to do that is to do something like this



for (var i=0; i<numberOfBullets; i++)
{
this.hitTest(thingYouAttachedBulletsTo["bullet" + i]);
}


this code would check collision (if i got the hitTest function right, ive never used that) for every bullet by taking the string "bullet" and adding whatever i is to the end of it.

unfortunatly, you would have a loop running every frame for every enemy and hit testing every bullet that bullet that has been created (unless you can figure out how to get it to skip bullets that have already hit something/moved off the screen, but i dont know how to do that :puzzled: )