# Collision against multiple move clips in an array - advice needed!

**URL:** <https://forum.kirupa.com/t/collision-against-multiple-move-clips-in-an-array-advice-needed/282046>\
**Category:** programming\
**Created:** [February 17, 2009, 3:56am UTC](https://forum.kirupa.com/t/collision-against-multiple-move-clips-in-an-array-advice-needed/282046 "2009-02-17T03:56:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tennoken](https://avatars.discourse-cdn.com/v4/letter/t/90db22/32.png) [@Tennoken](https://forum.kirupa.com/u/Tennoken)\
**Post date:** [February 17, 2009, 3:56am UTC](https://forum.kirupa.com/t/collision-against-multiple-move-clips-in-an-array-advice-needed/282046/1 "2009-02-17T03:56:53Z")

</div>

Hi everyone!

This is my first post to the boards, so be gentle 🙂

I’m writing a small game that involves a projectile move clip checking for collision against multiple target movie clips using an array. The scene is set to 800 x 600 @ 30 fps.

My issue is my fps dropping rapidly if there are multiple projectiles in flight: there are currently anywhere from 250 - 750 target MCs (20 x 20 pixels) and 3 to 6 projectile MCs (10 x 10 pixels) in action at any given time.

The target MCs are all part of class that .push into an array onLoad:

```auto

function onLoad()
{
         _root.targetArray.push(this);
         _root.DEBUG_potentialTargets++; // tracking total number of targets
}

```

And have one function:

```auto
function destroyMe()
{
			
	for(var i in _root.terrainArray)
	{
		if(_root.terrainArray* == this)
		{
			_root.terrainArray.splice(i,1);
			_root.DEBUG_potentialTargets--;
		}
	}
	this.removeMovieClip();
}

```

The projectile MC is checking every frame for a collision with anything in the root.targetArray with:

```auto
function onEnterFrame()
{
	
	// CHECK the targetArray for collision
	for(var i in _root.targetArray)
	{
		if(this.hitTest(_root.target*))
		{
			_root.targetArray*.destroyMe();
                        // and tell the target to remove itself
		}
	}
}

```

I’m very much an amateur coder - is there any way to optimize collision detection against such a large number of potential targets and still keep a decent framerate?
