DragonBones/DragonBonesAS — pull request #55 by thenitro (2014-11-13 13:52:58+00:00)
Title: public access to _currentTextureAtlas and _bitmapData for hit testing

for simple pixel perfect hittesting, yup there is no rotation and stuff, but in my case I have an big structures with small animations (like building with waving flags) its works almost perfecly

here is sample of code, you can include it, maybe its will be helpfull

public function hitTest(pTouch:Touch, pArmatureSprite:Sprite, pFactory:StarlingFactory):Boolean {
var bitmap:BitmapData = pFactory.getTextureAtlas(pFactory.currentTextureAtlasName).bitmapData;

for (var i:int = 0; i < pArmatureSprite.numChildren; i++) {
var image:Image = pArmatureSprite.getChildAt(i) as Image;
if (!image) {
continue;
}

var texture:SubTexture = image.texture as SubTexture;
if (!texture) {
continue;
}

var clip:Rectangle = texture.clipping;

var point:Point = pTouch.getLocation(image);
point.x += bitmap.width * clip.x;
point.y += bitmap.height * clip.y;

var pixel:uint = bitmap.getPixel32(point.x, point.y);
var alpha:int = (pixel >> 24) & 0xFF;

if (!alpha) {
continue;
}

return true;
}

return true;
};