Any thoughts on why my hitTest isn’t working?
obstColl = new Array();
//define obstacles and containers
allObst = new Array('holeObst','car1Obst','car2Obst','rockObst','truckObst');
var count:Number = 0;
function makeNewClip1() {
//depth = -8;
//interval and speed
clearInterval(ranID1);
ran1 = (Math.random()*12500)+1;
ranID1 = setInterval(makeNewClip1, ran1);
//pull random clip
clipID = allObst[int(Math.random()*allObst.length)];
//attach to root
count++;
newClip1 = _root.attachMovie(clipID,'clipID_mc',1+count);
obstColl.push(newClip1);
//position x and y
newClip1._x = 580;
newClip1._y = 100;
//control speed right to left
newClip1.speed = (Math.random()*5)+8;//ball fall speed
newClip1.onEnterFrame = function() {
this._x -= this.speed;
}
};
function makeNewClip2() {
//depth = -6;
//interval and speed
clearInterval(ranID2);
ran2 = (Math.random()*10000)+1;
ranID2 = setInterval(makeNewClip2, ran2);
//pull random clip
clipID = allObst[int(Math.random()*allObst.length)];
//attach to root
count++;
newClip2 = _root.attachMovie(clipID,'clipID_mc',2000+count);
obstColl.push(newClip2);
//position x and y
newClip2._x = 580;
newClip2._y = 130;
//control speed right to left
newClip2.speed = (Math.random()*5)+8;//ball fall speed
newClip2.onEnterFrame = function() {
this._x -= this.speed;
}
};
function makeNewClip3() {
// depth = -4;
//interval and speed
clearInterval(ranID3);
ran3 = (Math.random()*10000)+1;
ranID3 = setInterval(makeNewClip3, ran3);
//pull random clip
clipID = allObst[int(Math.random()*allObst.length)];
//attach to root
count++;
newClip3 = _root.attachMovie(clipID,'clipID_mc',4000+count);
obstColl.push(newClip3);
//position x and y
newClip3._x = 580;
newClip3._y = 160;
//control speed right to left
newClip3.speed = (Math.random()*5)+8;//ball fall speed
newClip3.onEnterFrame = function() {
this._x -= this.speed;
}
};
function makeNewClip4() {
// depth = -2;
//interval and speed
clearInterval(ranID4);
ran4 = (Math.random()*10000)+1;
ranID4 = setInterval(makeNewClip4, ran4);
//pull random clip
clipID = allObst[int(Math.random()*allObst.length)];
//attach to root
count++;
newClip4 = _root.attachMovie(clipID,'clipID_mc',6000+count);
obstColl.push(newClip4);
//position x and y
newClip4._x = 580;
newClip4._y = 190;
//control speed right to left
newClip4.speed = (Math.random()*5)+8;//ball fall speed
newClip4.onEnterFrame = function() {
this._x -= this.speed;
}
};
makeNewClip1();
makeNewClip2();
makeNewClip3();
makeNewClip4();
//
_root.createEmptyMovieClip('watchCollision', -2);
bike1.onEnterFrame = function() {
for (i=0; i<allColl.length; i++) {
if (allColl*.car1Obst.hitTest(_root.bike1)) {
trace("HIT CAR1");
_root.bike1.bike1_actual.nextFrame();
_root.bike1.bike1_actual.play();
}
if (allColl*.car2Obst.hitTest(_root.bike1)) {
trace("HIT CAR2");
_root.bike1.bike1_actual.nextFrame();
_root.bike1.bike1_actual.play();
}
if (allColl*.holeObst.hitTest(_root.bike1)) {
trace("HIT HOLE");
_root.bike1.bike1_actual.nextFrame();
_root.bike1.bike1_actual.play();
}
if (allColl*.rockObst.hitTest(_root.bike1)) {
trace("HIT ROCK");
_root.bike1.bike1_actual.nextFrame();
_root.bike1.bike1_actual.play();
}
if (allColl*.truckObst.hitTest(_root.bike1)) {
trace("HIT TRUCK");
_root.bike1.bike1_actual.nextFrame();
_root.bike1.bike1_actual.play();
}
}
};