PDA

View Full Version : hitTEST falling objects game



laxinlucy
March 9th, 2004, 07:45 PM
I am making a game where random things fall from the sky and the character must catch them by running into them before they hit the ground. I was wondering what the code would be if i wanted to make it so that there was always a certain number of falling objects.. like always 7.. so when the character ran into one and it was removed, another one would replace it...

flash4food
March 9th, 2004, 09:07 PM
u would have to name each of the objects like something1, something2, etc.

then do a loop of hittest on an enterframe handler like this


for(var i=0; i<7; i++){
if(this.hitTest(_parent["something"+i])){
//catching code
}
}

laxinlucy
March 9th, 2004, 10:32 PM
so should i put that code in the AS of the character?

flash4food
March 10th, 2004, 12:49 AM
yes

laxinlucy
March 10th, 2004, 10:09 AM
if i put this
for(i=0; i<10; i++){
fall.duplicateMovieClip("circle" + i, i+10);

}

in the frame AS so that a mc is duplicated is duplicated, then how could i use HitTest to with all of the duplicated movie clips

flash4food
March 10th, 2004, 09:34 PM
use the same code, only change something for circle and the 7 by 10