AS3 Collision Detection Kit

Ever wonder, is there an easier way instead of making loops and check for every hitTest with all sorts of  shapes and sizes? Well, may I present to you – Collision Detection Kit!

The Collision Detection Kit is a package of classes created for pixel-precise, shape-based collision detection for all display objects. It is written in Actionscript 3.0 and meant for Flash Player version 9 and higher.

The Collision Detection Kit comes with several features to control how collisions are detected, and provides data for the user of the class so they can do something about the collision:

  • Set an alpha threshold to ignore colors below the threshold.
  • Specify colors and color ranges to exclude from collision detection.
  • Receive an angle of collision for each collision. We’re not talking about bounding boxes here – the angle is calculated based on the shapes of the display objects at the site of the collision. Great for when you’re working with physics!
  • Receive the pixels that overlapped in a collision in stage coordinates. Combined with the returned angle, and your physics engine will have no problems traversing complicated shapes or performing off-axis rotation.
  • Takes transformations (scale, rotation, color transforms, etc.) of individual instances of your display objects into account.
  • Add items for collision detection regardless of their nesting.
  • You can have as many CollisionGroup and CollisionList instances as you want, allowing you to easily manage different interactions and behaviors.
  • Works with all display objects – MovieClips, Sprites, Bitmaps, TextFields, FLVs, and on and on!

Check out CDK in action below!