1. Computing

ActionScripting Basics: Collision Test Using hitTest

By

Determining collision action between two objects is one of the most important parts of ActionScripting that you can learn; it’s essential for almost any game that you might put together, and is even useful in content delivery and web designs. We’re going to demonstrate a simple collision action in which one animated object, the projectile, collides with another animated object, the target, and triggers some reaction in the target.

To start off with, create a basic projectile. Square are best until you get used to this; the hitTest determines what area counts as collision by an object’s bounding box, and irregular objects will still have a square bounding box—so they may seem to “collide” before the projectile actually enters the visible area of the object.

So: projectile. A small square, which you can then turn into a movie clip symbol. Give it an instance name—something simple and easily identifiable, like “projectile”.

©2014 About.com. All rights reserved.