4 Replies Latest reply on Mar 10, 2007 7:43 PM by chad1416

    need help with hit.test

    chad1416
      could someone help me. im making a game and i was wondering if theres a way to make it if my character walks into somthing it goes to a differnet frame
        • 1. Re: need help with hit.test
          2m Level 2
          hitTest seem to be the way indeed, so try it that way, or give us a more detailed description of your problem if you want us to be more helpful.
          • 2. need help with hit.test
            chad1416 Level 1
            quote:

            Originally posted by: 2m
            hitTest seem to be the way indeed, so try it that way, or give us a more detailed description of your problem if you want us to be more helpful.


            well its to long to explain but i need help making a code thats says when man touches wall go to this frame
            • 3. Re: need help with hit.test
              jthereliable Level 1
              Okay, there are 2 ways to use hitTest.
              1) Really inaccurate "box-like" hitTest
              2) Point hitTest, semi-accurate

              There is no "perfect" hitTest that can be run only once.

              If you want a crude hitTest, just do:
              if(MAN.hitTest(WALL))
              {
              gotoAndStop(FRAME);
              }

              A warning though:
              If the wall is an L shape, there will be a hitTest even though the man is not "touching" the wall. As long as it is within a rectangular boundary of the wall, it will be considered "hitting" it. Another example is a circle, the man could be along the top right corner but not touching the circle.

              The next one is:
              if(WALL.hitTest(MAN.x, MAN.y, true))
              {
              gotoAndStop(FRAME);
              }
              This code is better. However, the man can be "touching" the wall and not be "hitting" it. As long as the (x,y) coordinates of the man is not touching the wall, the man isn't hitting it.

              The best way I could find (but takes a heck longer) is by using two for loops (one with width, one with height) and checks a plus sign (+) of coordinates and makes sure that those points are touching both the man and the wall to call it a hit.

              Well, I hope this helps!
              • 4. need help with hit.test
                chad1416 Level 1
                yeah that helped thanks but now i got another problem... with buttons i know how to do them generally but i want on the over clip i want it to play a movie clip that i have on the over clip but it only goes to the second clip of the movie clip and loops i want it to play the whole thing then loop and i dont know how i did it but i had it doing that at one time