A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Help with collision detection!?

  1. #1
    Senior Member
    Join Date
    Nov 2000
    Posts
    203
    Can anyone tell me how to do a collision detection? I tryed the tutorial, but it's in Flash 4 and doesn't work when I tryed it myself.

    I'm doing this: I have 2 circle graphics in a movie clip, then when there is a collision, I want the one movie clip w/ circle graphic to change its alpha to 0.

    Thanks,


  2. #2
    Senior Moderator
    Join Date
    Apr 2000
    Location
    Sheffield, UK
    Posts
    3,881
    add this script to each movieclip:

    onClipEvent(enterframe){
    distance = Math.sqrt((_x-_root.movieclip2._x)*(_x-_root.movieclip2._x)+(_y-_root.movieclip2._y)*(_y-_root.movieclip2._y));
    if (distance<=_width/2+_root.movieclip2._width/2){
    _alpha=0
    }
    }

    now change the movieclip name that says movieclip2 to movieclip 1 when you assign the script to the second movielip!

    Hope that helps!
    Regards FlashGuru

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