Groups | Blog | Home
all groups > flash actionscript > march 2004 >

flash actionscript : complicated interactive hitTest


F??? ?? ?lash
3/29/2004 9:58:22 PM
I have 3 moving clips. I want them to be able to bounce of each other. I have
tried in vain to make this happen.

Anybody have an idea on where to insert my code? Have an idea on what kind of
code?

thanks
Dominik
kglad
3/30/2004 7:30:14 AM
it would probably be easiest to put that code on the main timeline in a
setInterval()-loop that would poll the position of your movieclips on each
loop. the code you would use depends upon what effect you are seeking. if
you're modeling physics with realistic bounce angles and speeds, then this
could be complicated requiring you to track the direction of each box so when a
collision occurs you can predict the effect on the two boxes. you also need to
decide how motion starts and the effect of boxes hitting boundaries.
F??? ?? ?lash
3/30/2004 12:49:34 PM
Hi.
I'm not going for a ultra-realistic physics collisions. I have thought about
it and it would take too much time. I just want the fastest clip to add his
speed (xspeed, yspeed) to the clip he collides with. I have a function that
evaluates the fastest, second and last clip. (speed wise)

I thought that calling the evaluation everytime a speed modifying event
happened would work. ex: when you launch a movieclip its speed (along with the
others) is evaluate to determine the fastest...

what should i do from here?

thanks,
Dom
kglad
3/30/2004 3:29:55 PM
i would use one loop to check for hits and then make adjustments to speeds and
directions. for example:

testI=setInterval(testF,100);
function testF(){
for(i=1;i<=3;i++){
// you can put a boundary collision test here
for(j=1;j<=3;j++){
if(i!=j){
if(_root["box"+i].hitTest(_root["box"+j])){
// do something. there's been a collision between two boxes
}
}
}
AddThis Social Bookmark Button