Sunday, March 24, 2013

Part 5 Collision Detection

Collision  detection. We have to do  2  detections so for him walking I have a wall where is detects on the left side so to do that. You make a wall a symbol and In ActionScript, there are two methods of the DisplayObject class that provide collision detection capabilities. These are:
hitTestObject() - checks whether the bounding boxes of any objects intersect.
hitTestPoint() - checks whether a certain x-y coordinate intersects with an object

I Used hitTestObject object  which is the simplest of the two.

example code
if(wall.hitTestObject(man))





This is my wall I know it  doesn't  look like much of a wall but it will also I have coded in a   text-field. So when you Hit it will trace out hit and on the stage. I  haven't  figured out how to stop him going through the wall yet.



No comments:

Post a Comment