PDA

View Full Version : Hit-testing Multiple Clips


msnyder
12-01-2006, 07:29 PM
I'm using Flash 8, trying to make a game. The problem is that there is a lot of one movieclip, they happen to be boxes, and basically my issue is trying to figure out a way in which to have one set of collision code work for all the boxes. My original idea was to add a line for each side of the box (Top, Left, Right, Bottom), and which the way my code works i want to disable the ability to move in that direction once you collide with the box. The problem with this is I do not know how to refer to lines made in my movieclip to represent the boundries of the box and not let the moving character go past them.

onClipEvent (enterFrame) {

if (this.hitTest(_root["TopLine"]))
{
movespeedUp=0
}
else
movespeedUp= 11
}

this is my code for stopping the character from going outside the frame. The movespeedUp is declared at the beggining of the code :

onClipEvent (load){
moveSpeedRight=11
moveSpeedLeft=11
moveSpeedUp=11
moveSpeedDown=11
}

Basically, my question is how do I refer to the moveSpeedRight property when in another movieclip?