Language Version: Actionscript 3.0
Player Version: Flash Player 9
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 consists of three classes:
- CDK - an abstract class that provides the majority of the logic. Cannot be instantiated.
- CollisionGroup - extends CDK, detects collisions against all possible pairings of display objects within it.
- CollisionList - extends CDK, takes each display object within it and checks for collisions against a single target display object.
The Collision Detection Kit comes with several features to control how collisions are detected, and provides useful data so the user of the class 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, as well as the transformations of any parent display objects.
- Add items for collision detection regardless of their nesting.
- Works with display objects not on the display list; great with blitting!
- 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 what it can do for you, reference the documentation for its classes:
CDK
CollisionGroup
CollisionList