import flash.geom.Point;
import flash.display.BitmapData;
this.onEnterFrame = function():Void
{
if (Box1.pixelHitTest(Box2))
{
//透明化
this.Box1._alpha = this.Box2._alpha = 10;
}
else if (Box1.pixelHitTest(Box3))
{
this.Box1._alpha = this.Box3._alpha = 10;
}
else
{
this.Box1._alpha = this.Box3._alpha = 100;
this.Box1._alpha = this.Box2._alpha = 100;
}
};
this.Box1.onPress = this.Box2.onPress = startDrag;
this.Box1.onRelease = this.Box2.onRelease = stopDrag;
MovieClip.prototype.pixelHitTest = function(mc:MovieClip):Boolean
{
var thisBitmap:BitmapData = new BitmapData(this._width, this._height, true, 0);
thisBitmap.draw(this);
var mcBitmap:BitmapData = new BitmapData(mc._width, mc._height, true, 0);
mcBitmap.draw(mc);
if (thisBitmap.hitTest(new Point(this._x, this._y), 0xFF, mcBitmap, new Point(mc._x, mc._y)))
{
return true;
}
return false;
};
- Apr 06 Wed 2011 17:18
Actionscript 碰撞偵測
close
全站熱搜
留言列表
發表留言