zoukankan      html  css  js  c++  java
  • 白鹭引擎

    class Main extends egret.DisplayObjectContainer {
    
        /**
         * Main 类构造器, 初始化的时候自动执行, ( 子类的构造函数必须调用父类的构造函数 super )
         * constructor 是类的构造函数, 类在实例化的时候调用
         * egret.Event.ADDED_TO_STAGE, 在将显示对象添加到舞台显示列表时调度
         */
        public constructor() {
            super();
            this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
        }
    
        /**
         * 1, 调用 显示对象.graphics 属相是一个 Graphics 对象, 用于绘制矢量图
         * 2, Graphics 对象含有大量绘制矢量图的方法, 具体方法看最后面的图
         * 3, 线段的绘制, 绘制前需要制定样式  lineStyle( 粗细值, 颜色 )
         * ---graphics.moveTo(x, y) 指定起点线段, lineTo 指定下一个点
         * 4, graphics.endFill() 方法结束当前绘画的设定, 并绘制
         * 5, graphics.curveTo(x1, y1, x2, y2) 方法绘制二次贝塞尔曲线
         * 6, graphics.drawArc(x, y, 半径, 起点的角度, 重点的角度, 是否逆时针绘制)
         * 7, graphics.clear() 方法用于清空显示对象的所有绘制
         */
        private onAddToStage(event: egret.Event) {
    
            var shp:egret.Shape = new egret.Shape();
            shp.graphics.lineStyle(10, 0x00ff00);
            shp.graphics.moveTo(100, 100);
            shp.graphics.lineTo(200, 200);
            shp.graphics.lineTo(300, 200);
            shp.graphics.curveTo(400, 400, 500, 200);
            shp.graphics.endFill();
            this.addChild(shp);
    
            var shape1:egret.Shape = new egret.Shape();
            shape1.graphics.beginFill(0xffff00);
            shape1.graphics.drawArc(100, 100, 50, 0, Math.PI, false);
            shape1.graphics.endFill();
            this.addChild(shape1);
    
            shp.graphics.clear();
        }
    }

  • 相关阅读:
    ## 序列化和反序列化
    C#小型资源管理器
    codeforces #310 div1 B
    codeforces #310 div1 A
    BZOJ 1030 文本生成器
    BZOJ 2806 cheat
    BZOJ 2553 禁忌
    BZOJ 4199 品酒大会
    codeforces #309 div1 D
    codeforces #309 div1 C
  • 原文地址:https://www.cnblogs.com/lovling/p/8399808.html
Copyright © 2011-2022 走看看