2017-04-21 32 views
1

我有一个sprite,其中包含重叠shape s。精灵本身将其alpha设置为.5,所以我必须将精灵的blendmode设置为“图层”,以防止重叠部分彼此透明。在从here获取的截图中,它应该看起来像右边的那个。AS3:使用alpha和blendmode的BitmapData.draw具有不正确的结果

enter image description here

现在我想draw一个bitmapData从我的精灵,但我不能得到所生成位图看起来像右边的图像。它最终看起来像中间的图像。

spriteBMD.draw(mySprite,null,mySprite.transform.colorTransform,"layer"); 

有没有人知道我在做什么错?

+0

只是胡乱猜测。尝试将其放入容器和绘图容器中,而不是目标精灵。 – Organis

回答

1

我有根源的一些想法,但无论如何,在这里它的工作原理:

import flash.display.BitmapData; 
import flash.display.BlendMode; 
import flash.display.Bitmap; 
import flash.geom.ColorTransform; 

var bmd:BitmapData = new BitmapData(mc.width, mc.height); 
var bitmap:Bitmap = new Bitmap(bmd); 

var sourceTransform:ColorTransform = mc.transform.colorTransform; 
var bmdTransfrom:ColorTransform; 

if(mc.blendMode == BlendMode.NORMAL) 
{ 
    bmdTransfrom = sourceTransform; 
}else 
{ 
    bitmap.transform.colorTransform = sourceTransform; 
} 

bmd.draw(mc, null, bmdTransfrom, mc.blendMode); 

addChild(bitmap);