egret 简单的截屏操作,三种图形渲染方式

所谓截屏就是将当前画面保存下来,只需两行代码

1 //截屏操作
2             let render = new egret.RenderTexture();
3             let rootLayer = this;
4             render.drawToTexture(rootLayer);//rootLayer是当前显示层的总容器,或者用this.stage
5             let base64Str = render.toDataURL("image/png");
6             render.saveToFile("image/png", "aa.png");//也可以保存下来

 白鹭图形渲染三种方式

1  icon.blendMode = egret.BlendMode.NORMAL;//默认模式, 覆盖效果
2          icon.blendMode = egret.BlendMode.ADD; //溶解效果
3          icon.blendMode = egret.BlendMode.ERASE;//擦除效果

this.addChild(icon);

滤镜中的投影滤镜

 1 //白色背景
 2         var bg: egret.Sprite = new egret.Sprite();
 3         bg.graphics.beginFill(0xffffff);
 4         bg.graphics.drawRect(0, 0, this.stage.stageWidth, this.stage.stageHeight);
 5         bg.graphics.endFill();
 6         this.addChild(bg);
 7 
 8         var bmp: egret.Bitmap = new egret.Bitmap(RES.getRes("mario_png"));
 9         this.addChild(bmp);
10 
11         var bmp2: egret.Bitmap = new egret.Bitmap(RES.getRes("mario_png"));
12         bmp2.y = 400;
13         this.addChild(bmp2);
14 
15         //投影滤镜
16         var shadowFilter: egret.DropShadowFilter = new egret.DropShadowFilter(40, 60, 0x000000, 0.8, 16, 16, 0.6, egret.BitmapFilterQuality.LOW, false, false);
17         bmp2.filters = [shadowFilter];

posted @ 2019-03-02 16:37  猪猪快冲  阅读(2006)  评论(0编辑  收藏  举报