5 Replies Latest reply on Jun 10, 2010 12:26 AM by HoneyBadger87

    collision detection

      I need to do collision detection for a dart hitting some balloons. I d/l'd the Skinner sample movies. The provided SWFs work, but compiling a SWF from the provided FLA does not! I didn't edit the file, just opened and compiled. So what could possibly keep the code from working?!

      Using F8 pro on a mac.
        • 1. Re: collision detection
          Damon Edwards Level 3
          what doesn't work like it should? are you getting any compiler errors or runtime errors?
          • 2. Re: collision detection
            Level 1
            No errors reported. I compiled both sample FLAs he provided and they run, but no collision is triggered like in the provided SWFs. Dragging the ball in the first one never makes the maze shape turn red, and the balls in the second one float right over the spinning shape without exploding.

            I gotta get the detection working by Monday am. Would hitTest work instead for an oval?
            • 3. Re: collision detection
              clbeech Level 3
              it may be that you do not have Grant's collisionDetection class file within the folder.

              however, yes for your situation it's most likely that you can use the native Flash hitTest method with a shpae flag for what you would like to do here. since really you only need to to test a single 'point' (eg. the tip of the dart) against the balloon instances. the easiest way to do so would be to have your darts set up so that the registration point is at the tip - then of course you can rotate the dart to a trailing position on the flight path with a bit of math. but setting the registration at the tip is important because you can then simply use the x/y coordinates of the dart in the hitTest method - while iterating through the balloon instances in the field - all of course within a loop during the dart's flight.

              here's some discussion on the native Flash hitTest methods: HERE
              • 4. collision detection
                Level 1
                I had rejected hitTest as a viable option because it looked like I was getting bounding box testing rather than shape testing, even when setting the shapeflag. But after seeing the previous post and trying again, I figured out that the positive results were because the transparent areas of my png were not transparent to hitTest. Kinda like bumping into Wonder Woman's invisible jet....

                Testing on a round flash shape worked. So for what it's worth, don't anyone else expect non-visible areas of a png to return false with hitTest. I worked around this issue and am happily coding on!

                • 5. Re: collision detection

                  Hello !


                  I am working over the collision between balls. Using native functions detects the object and has oriented bounding box. so the collision looks bad. help me with some feeds for implementing an optimised collision !




                  HoneyBadger .