+ Post New Thread
Results 1 to 6 of 6
Coding Thread, Flash Collision Detection? in Coding and Web Development; Basically i have my little car goin around but if it hits the sides it doesnt do anything i want ...
  1. #1

    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

    localzuk's Avatar
    Join Date
    Dec 2006
    Location
    Minehead
    Posts
    17,794
    Thank Post
    517
    Thanked 2,468 Times in 1,912 Posts
    Blog Entries
    24
    Rep Power
    835
    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 (28th November 2009)

  4. #3

    Join Date
    Nov 2009
    Location
    Gloucestershire
    Posts
    3
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    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

    Join Date
    Nov 2009
    Posts
    4
    Thank Post
    3
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    its as3 but thnx for the tips (:

  6. #5
    StewartKnight's Avatar
    Join Date
    Jun 2005
    Posts
    1,587
    Thank Post
    2
    Thanked 27 Times in 21 Posts
    Rep Power
    30
    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 (30th November 2009)

  8. #6

    Join Date
    Nov 2009
    Posts
    4
    Thank Post
    3
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    my email adress is jonnyebr@hotmail.com
    thnx alot

SHARE:
+ Post New Thread

Similar Threads

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

Thread Information

Users Browsing this Thread

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

Posting Permissions

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