Flash as3: Framedifferencing collission detection (hitTest)

Combination of Frame Differencing and hitTest in as3. Inspired by the Processing sketch of Andy Best where you can pop bubbles if there is movement. By checking the difference between two frames (current and the previous one) we know where there was movement. The movement is stored in a bitmap and with that we can do a collission detection with other bitmap objects in the screen.

In the example below you’ll see two balls that change colour and position when hit. Code is in the zip-file.

See my post about Frame differencing for other Flash and Processing examples.

Used resources

  • Using BitmapData.hitTest for Collision Detection by Mike Chambers
  • <li><a href="http://actionsnippet.com/?p=2820">code snippet from Zevan</a></li>

    Download : Framedifferencing collision detection – source code

    If you have suggestions for more improvements, please give your feedback in the comments.

    Leave a Comment

    This site uses Akismet to reduce spam. Learn how your comment data is processed.