Bitmap Collison Detection with ActionScript 3
Sep/071
I finally got around to converting Grant Skinner’s collision detection algorithm to ActionScript 3. This version primarily takes advantage of the latest library class/method additions.
For anyone familiar with Grant’s implementation, you’ll notice the method signature is similar.
To determine whether or not the bitmap data values of two display objects are “colliding”, you simply call:
var x:Rectangle = Collision.collisionTest(myObj, yourObj);
Alternatively, you may also pass a third argument representing the alpha tolerance which in turn gets passed to the alphaTolerance argument of the ColorTransform constructor.
var x:Rectangle = Collision.collisionTest(myObj, yourObj, alphaTol);
You can see an example, here or download the Class definition, here.
