Collision Detection in Flash Functionalities? (hitTestObject)

折月煮酒 提交于 2019-12-02 09:58:22
CodeMouse92

As you correctly notice, hit areas in hitTestObject are by default rectangular, as they use the bounding box.

You can test against the object's actual shape on a point-by-point basis using...

hitTestPoint(someobject.x, someobject.y, true);

(See the documentation.)

For custom-shaped hit areas, you can also use bitmap hit testing. (See accepted answer here.)

Collision detection has been a major hurdle for coders for years. There are many different methods for detecting collisions:

I found hitTestPoint to be the most practical. However, in your case you may want to go along the lines of BitmapData: http://www.freeactionscript.com/2011/08/as3-pixel-perfect-collision-detection/

Cheers, Drake Swartzy

you can do it this way if(instanceName1.hitTestObject(instancename2) == true) { //execute the code you want } instanceName1 and 2 are the given name in the porgram

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!