Case:
You got 20 movieclips moving around on a stage, bumping into things.
What’s the best way to check if the MCs hit the things.
The Movieclips move around randomly on the stage…
So, do I have to check if the MC bump into a thing through listing
each object with hitTest(this,thing1), (see first code below) or is it possible to do it even easier (see bad code at the end of the post)?
Using the code below ends up in 5 loops per object per frame…
Suggestion code:
arr a = new Array(thing1,thing2,thing3,thing4)
for(i=0;i<=4;i++)
{
if(hitTest(this,a*)==true)
{
changeDirection()
}
}
}
Maybe possible:
var k = all things as one object
if(hitTest(this,k)==true)
{
changeDirection()
}