如何将 BitmapFilter 渲染到 BMD?
如何将应用于精灵的 BitmapFilter(例如 DropShadowFilter)渲染到单独的 BitmapData 层?然后将其放置在所有物体下方。
例如,如果您有两个彼此重叠的矩形精灵,并且对每个精灵应用了 DropShadowFilter,则结果将是滤镜覆盖并遮挡另一个矩形精灵 - 如下所示。
注意:每个过滤器可能有不同的设置,因此我不能只将统一的过滤器应用于包含的精灵。 另外:理想情况下,该解决方案可以扩展以同时处理许多动画精灵。
How would you render a BitmapFilter (such as DropShadowFilter) applied to a sprite, to a seperate BitmapData Layer? which would then be placed beneath all objects.
For instance if you have two rectangular sprites overlapping each other, with a DropShadowFilter applied to each, the result would be the filter overlaying and obscuring the other rectangular sprite - as shown below.
note: each filter may have different settings and so I cant just apply a uniform filter to a containing sprite. also: ideally this solution will be scalable to handle many animated sprites at the same time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我想说最简单的方法是保留每个 Sprite 的轮廓副本,并对其应用 DropShadowFilter。在滤镜上,设置
dropShadowFilter.hideObject = true;
- 这将仅渲染阴影。然后将所有轮廓阴影添加到单个容器 Sprite 中并使用 addChildAt(container,0) ,因此它将渲染在其他所有内容的下方。I'd say the easiest way to do this is to keep an outline copy of each of your Sprites, to which you apply the DropShadowFilter. On the filter, set
dropShadowFilter.hideObject = true;
- this will render only the shadow. Then add all the outline shadows to a single container Sprite and useaddChildAt(container,0)
, so it will be rendered below everything else.我的方法是将每个
DisplayObject
的过滤器属性knockout
设置为true
绘制到BitmapData
对象,然后重置每个过滤器的knockout
恢复到原始状态。一个简单的例子来证明这一点:My approach would be drawing each
DisplayObject
with it's filter's propertyknockout
set totrue
to aBitmapData
object, then reseting each filter'sknockout
to original state. A quick example to demonstrate this:我认为您正在寻找 BitmapData.applyFilter()。它将任何 BitmapFilter 类型应用于 BitmapData 对象。位图滤镜是一系列滤镜类型的父类,包括模糊、发光和着色器滤镜。
http://help.adobe.com /en_US/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html#applyFilter()
http://help.adobe.com/en_US/FlashPlatform /reference/actionscript/3/flash/filters/BitmapFilter.html
I think you are looking for BitmapData.applyFilter(). It applies any BitmapFilter type to your BitmapData object. Bitmap filter is the parent class for a bunch of Filter types, including Blur, Glow, and Shader filters.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html#applyFilter()
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filters/BitmapFilter.html