defkon2012
Programmer
I have a problem with this game I am making.
I need a better way to detect if a enemy ship has come into contact with one of the hero's bullets. Right now on every enemy I have a if statement that has way too many || or statements in it. I have 40 different friendly bullets that need to be checked for hitTest within my if statement.
So I have something that looks like this...
CODE FOR ENEMY SHIP
if(this.hitTest(bullet01)||this.hitTest(bullet02)||this.hitTest(bullet03)... ect ect
all the way to bullet40.
now when I have multiple enemys on screen all running this incredible if statement, I have a major problem with processor speed.
So my question is, would anyone know how to do this better? I have been thinking there is a way using the
substring() function. Using it to detect if the characters "bullet" is in a string. But I have had problems incorporating it with a if and hitTest statement.
does anyone have a suggestion on how to detect if a movieClip has come into contact with one of 40 other movieClips without running 40 if statements or ||?
thank you
defkon2012
I need a better way to detect if a enemy ship has come into contact with one of the hero's bullets. Right now on every enemy I have a if statement that has way too many || or statements in it. I have 40 different friendly bullets that need to be checked for hitTest within my if statement.
So I have something that looks like this...
CODE FOR ENEMY SHIP
if(this.hitTest(bullet01)||this.hitTest(bullet02)||this.hitTest(bullet03)... ect ect
all the way to bullet40.
now when I have multiple enemys on screen all running this incredible if statement, I have a major problem with processor speed.
So my question is, would anyone know how to do this better? I have been thinking there is a way using the
substring() function. Using it to detect if the characters "bullet" is in a string. But I have had problems incorporating it with a if and hitTest statement.
does anyone have a suggestion on how to detect if a movieClip has come into contact with one of 40 other movieClips without running 40 if statements or ||?
thank you
defkon2012