PDA

View Full Version : Please: need help on a hit test for class project



james69
March 4th, 2005, 10:11 PM
function createPig (i){
mov = "clip"+i;
_root.attachMovie("myMC", mov, i);
_root[mov]._x = -20;
_root[mov]._y = Math.random()*250;
_root[mov].speed = Math.random()*5+5;
_root[mov].onEnterFrame = fly;
}
function fly(){
this._x+=this.speed;
if(this._x > Stage.width){
this.unloadMovie();
_root.num++;
_root.createPig(_root.num);
}
}
_root.maxNum = 7;
for(_root.num=1; _root.num<_root.maxNum; _root.num++){
createPig(_root.num);
}

what would be the hittest for the pig for this duplicate/random for this mc. I am using a crosshair to hit the pigs. I am new at actionscript. Thank you for anyones help

Marz
March 8th, 2005, 01:35 PM
If you are only using the seven pigs... Just make a for loop in the main function onEnterFrame(). Btw, also change your _root.num to something lighter and easier to use like i and change the i in your function name to something more descriptive like pigNumber or pigID.




for(i=1; i<_root.maxNUm; i++)
{
_root["clip"+i].hitTest(_root.crosshair);
}


It would be something along those lines.