dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: collide react

  1. #1
    Senior Member cyber reaper's Avatar
    Join Date
    Apr 2004
    Location
    israel
    Posts
    272

    collide react

    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
    ok....what ?

  2. #2
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    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.

  3. #3
    Senior Member cyber reaper's Avatar
    Join Date
    Apr 2004
    Location
    israel
    Posts
    272
    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...
    ok....what ?

  4. #4
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Here's an example file. Drag the circles to test collision.
    Attached Files Attached Files

  5. #5
    Senior Member cyber reaper's Avatar
    Join Date
    Apr 2004
    Location
    israel
    Posts
    272
    ohhhh .... so thats what i was missing , i forgot to condition the whole script with a veriable....

    well , thanks again , its been a big help , as usual !
    ok....what ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center