+ Reply to Thread
Results 1 to 6 of 6

Thread: Flash Collision Detection?

  Share/Bookmark
  1. #1

    Reputation

    Join Date
    Nov 2009
    Posts
    4
    Thank Post
    3
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Angry Flash Collision Detection?

    Basically i have my little car goin around but if it hits the sides it doesnt do anything i want it to move to another keyframe. If anyone flash experts know the codes then please help meee!!

    Thankz:P

  2. #2

    Reputation
    Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation
    localzuk's Avatar
    Join Date
    Dec 2006
    Location
    Minehead, Somerset
    Posts
    8,384
    Blog Entries
    22
    Thank Post
    264
    Thanked 755 Times in 604 Posts
    Rep Power
    197

    Default

    I'm not particularly a flash expert, but collision detection is pretty much the same whatever language. You need some form of script to monitor the objects, and see when their boundaries cross/touch.

    This video may help:

    [ame="http://www.youtube.com/watch?v=iUbX9tFtqTg"]YouTube- Flash AS3 Collision Detection[/ame]

  3. Thanks to localzuk from:

    Jonny_5 (28-11-2009)

  4. #3

    Reputation

    Join Date
    Nov 2009
    Location
    Gloucestershire
    Posts
    3
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    is it as2 or as3?
    When you move the car you want to get it's x and y position. Then use an if statement so that:

    if(car.x < 0) {
    // hit the left wall
    } else if(car.x > Stage.width) {
    // hit the right wall
    }
    if(car.y < 0) {
    // hit the ceiling
    } else if(car.y > Stage.height) {
    // hit the floor
    }

    You can adjust the values to take into account the car's width by using this instead:

    if(car.x-(car.width/2) < 0)


    Failing that use the hitTest method, placing movieclips around the outside. Check the Flash help for hitTest

  5. #4

    Reputation

    Join Date
    Nov 2009
    Posts
    4
    Thank Post
    3
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    its as3 but thnx for the tips (:

  6. #5

    Reputation Reputation Reputation
    StewartKnight's Avatar
    Join Date
    Jun 2005
    Posts
    1,718
    Thank Post
    2
    Thanked 26 Times in 20 Posts
    Rep Power
    22

    Default

    you need the hittest i.e.

    if (car.hitTest(line1)) {
    gotoAndStop(2);
    }
    if (car.hitTest(end)) {
    gotoAndStop(4);
    }
    };


    Instead of goto and stop, you could have nextFrame

    Send me your email address, and I'll email you some working code as a demonstration!

  7. Thanks to StewartKnight from:

    Jonny_5 (30-11-2009)

  8. #6

    Reputation

    Join Date
    Nov 2009
    Posts
    4
    Thank Post
    3
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    my email adress is jonnyebr@hotmail.com
    thnx alot

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. plagiarism detection
    By PEO in forum General Chat
    Replies: 9
    Last Post: 07-01-2010, 11:50 PM
  2. HP Procurve High collision or drop rate errors
    By techie08 in forum Networks
    Replies: 1
    Last Post: 11-03-2009, 11:37 PM
  3. AP's with rogue AP detection
    By Jobos in forum Networks
    Replies: 1
    Last Post: 02-03-2009, 06:20 PM
  4. Hardware Detection
    By Mr.Ben in forum Windows
    Replies: 1
    Last Post: 20-05-2008, 10:08 PM
  5. Detection of flash within browser regardless of ..
    By mac_shinobi in forum Web Development
    Replies: 3
    Last Post: 31-08-2005, 03:32 PM

Posting Permissions

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