Handeling Multiple Enemies
- kizza0
-
kizza0
- Member since: Oct. 13, 2007
- Offline.
-
- Forum Stats
- Member
- Level 08
- Blank Slate
Bassicaly, Im making a flash game for my multimedia class where you shoot an continuous stream of zombies. Every time you shoot i would like every alive zombie to be tested for a collision on the bullets path. Iv got the collision detection down but handling more than one enemy has got me down.
They will be added to the stage at random intervals and their will likely be 100's appearing in each game with less than 15 on the screen at any time. Iv thought about using an array to hold each spawned zombies name but I'm not sure how to remove that name once they die.
Any help would be appreciated.
BOOM HEADSHOT
- Sam
-
Sam
- Member since: Oct. 1, 2005
- Offline.
-
- Forum Stats
- Moderator
- Level 19
- Programmer
If your using duplicate/attach movieclip the simplest way would be to write the collision code on the zombie movieclip.
And to remove:
removeMovieClip(this); - kizza0
-
kizza0
- Member since: Oct. 13, 2007
- Offline.
-
- Forum Stats
- Member
- Level 08
- Blank Slate
Using actionscript 3.0 so that isnt an option :(
Thanks anyway.
BOOM HEADSHOT
- Sam
-
Sam
- Member since: Oct. 1, 2005
- Offline.
-
- Forum Stats
- Moderator
- Level 19
- Programmer
At 8/26/09 08:54 AM, kizza0 wrote: Using actionscript 3.0 so that isnt an option :(
Thanks anyway.
How about inside the movieclip and on it's frame? I'm pretty sure you could do something like that.
- henke37
-
henke37
- Member since: Sep. 10, 2004
- Offline.
-
- Forum Stats
- Member
- Level 30
- Blank Slate
The issue is more like that there is no such method in as 3, he needs to use removeChild on the container in combination with manually unregistering any listeners and clearing any reference to the MovieClip instance.
Each time someone abuses hittest, God kills a kitten. Please, learn real collision testing.
- GeoKureli
-
GeoKureli
- Member since: Apr. 1, 2003
- Offline.
-
- Forum Stats
- Supporter
- Level 19
- Game Developer
At 8/26/09 07:49 AM, kizza0 wrote: Bassicaly, Im making a flash game for my multimedia class where you shoot an continuous stream of zombies. Every time you shoot i would like every alive zombie to be tested for a collision on the bullets path. Iv got the collision detection down but handling more than one enemy has got me down.
They will be added to the stage at random intervals and their will likely be 100's appearing in each game with less than 15 on the screen at any time. Iv thought about using an array to hold each spawned zombies name but I'm not sure how to remove that name once they die.
Any help would be appreciated.
for(var i:int = 0; i < myArray.length; i++)
if(myArray[i].dead){//if enemy is dead
rootMC.removeChild(rootMC.getChildByName(myArray[i].name);//remove chid from parent
if(i+1 < myArray.length)//if not the last index in array
myArray[i] = myArray.pop();//remove child from array by moving last index to overwrite it
else//if this is the last index
myArray.pop()//remove it
} This blog I made | This game sucks | FlxGreed | Home Run Swingers: Rhythm Baseball
many typos
- kizza0
-
kizza0
- Member since: Oct. 13, 2007
- Offline.
-
- Forum Stats
- Member
- Level 08
- Blank Slate
BOOM HEADSHOT

