Im trying to do a hit test on individual objects in two seperate arrays.
one is an array of bullets populated each time the mouse is pressed, the other is an array of enemies that are created at timed intervals. So far I have failed at
every attempt and I would be extremely grateful for any help.
the code on the stage is as follows:
tick=0;
int (tock);
score=0;
speed = 10;
depth = 0;
nose = 50;
aaron = new Array();
aaron2 = new Array();
for(i=0; i<_root.aaron2.length; i++){
if (this._parent.hitTest(_root.aaron2*)) {
this._parent.removeMovieClip();
trace(“Hello”);
_root.damage=“gghvghv”;
}
}
_root.onMouseMove = function() {
updateAfterEvent();
};
_root.onMouseDown = function() {
loop_sound = new Sound();
loop_sound.attachSound(“boom.wav”);
loop_sound.setVolume(100);
loop_sound.start();
angle = cannon._rotation;
angle = angle*Math.PI/180;
++depth;
name = “ball”+depth;
_root.attachMovie(“ball”, name, depth);
_root[name]._x = cannon.gunref.point.x;
_root[name]._y = cannon.gunref.point.y;
_root[name].xmov = speedMath.cos(angle);
_root[name].ymov = speedMath.sin(angle);
aaron.push(name);
_root[name].onEnterFrame = function() {
this._x += this.xmov;
this._y += this.ymov;
}
};
//START OF 2ND CODE
_root.chopperholder.onEnterFrame = function(){
_root.timer=tock;
_root.a=tick;
tock++;
if(tock>1000){
tock=0;
}
if(tock==100||tock==300||tock==500||tock==700||tock==900){
name2 = “blue”+adepth;
_root.attachMovie(“blue”, name2, adepth);
_root[name2]._x = chopperholder.chopref.point2.x;
_root[name2]._y = chopperholder.chopref.point2.y;
adepth++;
aaron2.push(name2);
}
}
stop();
then on each of the movie clips i have the following code
onClipEvent(enterFrame) {
if (this._parent.hitTest(_root.right)) {
_root.damage=“Boundary Hit!”;
this._parent.unloadMovie();
}
if (this._parent.hitTest(_root.top)) {
_root.damage=“Boundary Hit!”;
this._parent.unloadMovie();
}
for(i=0; i<_root.aaron2.length; i++){
if (this._parent.hitTest(_root.aaron2*)) {
this._parent.removeMovieClip();
_root.damage="Collision detected";
}
}
}