标签:rap sha graph str play contain 形状 eve his
class ShapeTest extends egret.DisplayObjectContainer { public constructor() { super(); this.addEventListener(egret.Event.ADDED_TO_STAGE,this.onAddToStage,this); } private onAddToStage(event:egret.Event){ var shp:egret.Shape = new egret.Shape(); shp.graphics.lineStyle(10,0x00ff00);//第一个参数:描边的线条宽度,第二个参数是描边的颜色 shp.graphics.beginFill(0xff0000,0.8);//red 设置矩形的填充颜色,第二个参数是透明度;1表示透明度 shp.graphics.drawRect(0,0,100,200);//设置矩形的形状,绘制的是100*200的矩形 shp.graphics.lineStyle(10,0x00ff00);//无作用 shp.graphics.endFill();//结束当前绘制操作 若要对矩形加描边,可以设置线条的样式 //通关lineStyle方法来设置 代码需要放在绘制代码之前,否则无效,且不报错 this.addChild(shp); ///////////////////////清空绘制:将已经绘制的图像全部清空//////////////////////////////////////////////// //shp.graphics.clear(); } private drawCircle(event:egret.Event){ var shp:egret.Shape = new egret.Shape(); } }
标签:rap sha graph str play contain 形状 eve his
原文地址:https://www.cnblogs.com/allyh/p/10618570.html