以前就有网友问到,今天研究了一下,比以前的做法好多了!效率高!
以前的做法:
http://space.flash8.net/space/?284926/action_viewspace_itemid_372562.html现在基本思路:将要检测的MC转化为BitmapData,然后用其方法hitTest。as:
import flash.display.BitmapData;
import flash.geom.Point;
var bmp:BitmapData = new BitmapData(Stage.width, Stage.height, true, 0x00ffff);
bmp.draw(_mc);
var copy_mc:MovieClip = _root.createEmptyMovieClip("c_mc", 0);
copy_mc.attachBitmap(bmp, 2);
copy_mc._x = _mc._x;
copy_mc._y = _mc._y;
_mc._visible = false;
var startPoint
oint = new Point(copy_mc._x, copy_mc._y);
var endPoint
oint = new Point();
copy_mc.onEnterFrame = function() {
endPoint.x = _xmouse;
endPoint.y = _ymouse;
if (bmp.hitTest(startPoint, 0, endPoint)) {
trace(endPoint);
}
};
效果:
源文件:
碰撞检测.rar