Collision Detection-Multiple Objects:effectiveness

Greetings folks,

I’ve searched forum but found nothing to the topic.

Basics: I want to program a simple plane-shooter alike Raptor/Tyrian .

The problem is with detecting colisions between multiple objects. I went through “Collision Detection Among Multiple Objects” tutorial, but there you have to know the precise number of objects on the stage. Further on, you’ll need their names/ store them inside an array for referrencing.

Now in this game, there will be following objects to deal with:

grouped mc:
-mcSHIP
objects inside this mc:
-mcHULL (ship’s body)
-mcFIRE (missiles, lasers etc.)

grouped mc:
-mcHOSTILE
objects inside mc:
-METEOR mcs
-ENEMY_SHIPS mcs
-BUILDINGS mcs

grouped mc:
-mcBONUSES
objs inside this mc:
-mcHEALTH
-mcSHIELD
-mcWEAPON/ WEAPON UPGRADE
-mcCREDITS

This will make testing via hitTest a lotlot more easier, since 2 hittest functions will suffice:
SHIP.hitTest(HOSTILE) and SHIP.hitTest(BONUSES);

The problem is following:

All objects are generated and attached using attachMovie on the stage. Number of objects on Stage varies and is unpredictible. Names of those objects vary. When i do: SHIP.hitTest(HOSTILE) and get TRUE, i have to test WHICH from those HOSTILE objects from groupped(parent) mc HOSTILE colided with my HULL/FIRE(SHIP).

I can do it keeping track of ALL mcHOSTILE objects in array lt’s say aHostile, and so for every other groupped mc (mcBONUSES: aBonuses, mcSHIP: aShip) and when collision is detected(lets say with mcHOSTILE), loop through all aHOSTILE mc’s with hitTest and check for hitTest all of them separatedly…

This simplifying of hitTest tsting is CPU friendly, and that’s my main objective, though is there some better way to do this?

I am sure there is and any sugesstions are welcomed :wink: