1 Reply Latest reply on Feb 4, 2008 3:52 AM by Varangian

    BitmapData hitTest

    Varangian Level 1
      Ok I already asked about the hitTestObject. I didn't got an answer here.. but managed to find out that the hitTestObject works only with squarish objects. If a DisplayObject is a circle it will create a square and so collision would be detected pixels away from the real collision.

      I have taken the above from the link below.
      http://www.kirupa.com/forum/showpost.php?p=1922772&postcount=4

      Now to my question. I'v moved to using the hitTest method of the BitmapData. However I still cannot make a collision of two objects when they are rotated. How do I make a collision of two Image objects using the hitTest?
      Below is the code I'm using inside an AS Class.
      Also there is a parameter in this hitTest that I cannot understand which is the alpha Threshold. What is this?

      public function IsCollisionDetected(hitImage:DisplayObject):Boolean
      {
      var thisBmpData:BitmapData = new BitmapData(this.width,this.height,true,0);
      thisBmpData.draw(this);
      var hitImageBmpData:BitmapData = new BitmapData(hitImage.width,hitImage.height,true,0);
      hitImageBmpData.draw(hitImage);

      return thisBmpData.hitTest(new Point(this.x,this.y),255,hitImageBmpData,new Point(hitImage.x,hitImage.y),0);
      }

      Can anyone help please? If I should post in another forum like Flash or something tell me. I'm using Flex 2.
      Thanks in advance!