Click to See Complete Forum and Search --> : collide react
cyber reaper
01-17-2005, 04:03 PM
hello, i once saw blanious's collide reaction script , well i got the whole collide thing , but i never understood the circular collide script , can anyone give me the correct script plus a small movie file for example ?
thanks in advance , Cyber Reaper
blanius
01-17-2005, 09:01 PM
This is from my script file.
//*************************************
//simple distance test
//*************************************
function distance(element1,element2)
{
a=element1.x - element2.x;
b=element1.y - element2.y;
return sqrt (a*a+b*b);
}
//*************************************
//Circle Collide uses distance test function
//*************************************
function circleCollide(element1,element2)
{
//get width of both elements
width1=(element1.getBounds().xMax-element1.getBounds().xMin)-6
width2=(element2.getBounds().xMax-element2.getBounds().xMin)-6
//get distance
dist=distance(element1,element2);
//account for different sizes
width=(width1/2)+(width2/2);
//check distance and size
//return t/f
return dist<=width
}
basically it uses distance to determine if the objects are colliding.
cyber reaper
01-18-2005, 09:12 AM
eh.... well i hope its not too much truble sending me a .movie file so i could see exacly where those lines goes ... i hardly know anything about collisions so...
blanius
01-19-2005, 12:09 AM
Here's an example file. Drag the circles to test collision.
cyber reaper
01-19-2005, 10:09 AM
ohhhh .... so thats what i was missing , i forgot to condition the whole script with a veriable.... :D
well , thanks again , its been a big help , as usual ! :doughnut:
flashkit.com
Copyright Internet.com Inc., All Rights Reserved.