加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

AS3 倒影效果 www2.flash8.net 的带注释版

发布时间:2020-12-15 06:23:58 所属栏目:百科 来源:网络整理
导读:由于在RIA开发中需要对有水的地图场景做一些特效处理比如说倒影,如下图的效果,至于RIA:请访问q.uen.cn/ria/ria.html 因此,分享一下倒影算法的心得,首先观察倒影的特点如下: 1、是上下反转的图像 2、从上到下透明度越来越大 那么我来完成这2步操作: fu

由于在RIA开发中需要对有水的地图场景做一些特效处理比如说倒影,如下图的效果,至于RIA:请访问q.uen.cn/ria/ria.html



因此,分享一下倒影算法的心得,首先观察倒影的特点如下:
1、是上下反转的图像
2、从上到下透明度越来越大
那么我来完成这2步操作:

function?createRef(p_source:DisplayObject):void{?
???//对源显示对象做上下反转处理?
????var?bd:BitmapData=new?BitmapData(p_source.width,p_source.height,true,0);?
????var?mtx:Matrix=new?Matrix();?
????mtx.d=-1;mtx.ty=bd.height;?
????bd.draw(p_source,mtx);?
//生成一个渐变遮罩?
????var?width:int=bd.width;?
????var?height:int=bd.height;?
????mtx=new?Matrix();?
????mtx.createGradientBox(width,height,0.5?*?Math.PI);?
????var?shape:Shape?=?new?Shape();?
????shape.graphics.beginGradientFill(GradientType.LINEAR,[0,0],[0.9,0.2],0xFF],mtx)?
????shape.graphics.drawRect(0,width,height);?
????shape.graphics.endFill();?
????var?mask_bd:BitmapData=new?BitmapData(width,0);?
????mask_bd.draw(shape);?
//生成最终效果?
????bd.copyPixels(bd,bd.rect,new?Point(0,0),mask_bd,false);?
//将倒影位图放在源显示对象下面?
????var?ref:Bitmap=new?Bitmap();?
????ref.y=p_source.height;?
????ref.bitmapData=bd;?
????p_source.parent.addChild(ref);?
}

源显示对象如图:



生成的倒影效果:

/UploadTeach/200709/20070926114831863.swf

如看不到SWF,请看下面截图:

当然你也可以加入一些水波效果以达到更COOL的效果。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读