Collision Detection Kit in AS3 (lessthanthree)

Collision Detection Kit: Pixel-precise, shape-based collision detection for ActionScript 3.0

Republished from the Google Code page.
Download the source code here.

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 amount of overlapping pixels between colliding objects. Combined with the returned angle, and your physics engine will have no problems traversing complicated shapes.
  • 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!

To learn more about this package and how to use it, please reference the links for examples and documentation.

Tags: , , , , , , , ,

One Response to “Collision Detection Kit in AS3 (lessthanthree)”

  1. blaackjack says:

    Hi ! I’m using your color detector, wich is incredibly amazing. Meanwhile i’ve got a problem: When i add sprites, or draw graphics inside my displayObjectContainer who will be added into the collision list, it appears to have some lagging when the sprites are shown on the stage. But when the sprites are not visible on the stage, the collision work perfectly when the stage only show the displayObjectContainer