Tuesday, August 23, 2005

Sometimes when you code collision detection in your game, you need the bounding box of your movieclip to be of different size or shape than the bound of the movieclip itself. One quick way to do this is to create a new layer in your mc, say hitarea or whatever you like. Insert a clip (call it mcHitArea) in that layer, resize it to your liking. Within mcHitArea, put this code in the first frame of your actionscript layer:

this._parent.hitarea = this;
this._visible = false;

There is no need to name the mcHitArea instance, because you will be using the MovieClip.hitArea property to get to it.

if (mc.hitArea.hitTest(obj))
{
...
}

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home