1: 白鹭引擎默认实在一个 640 * 1136 的画布上作画

2: 入口文件 Main.ts,  类 Main 是程序的入口

// 1, 在一个宽高为 640 * 1136 的画布上作画
// 2, 动态测试的 CMD 命令: egret startserver -a
// 3, 类 Main 是程序入口类, 是最基本的显示对象
// 4, egret 提供的核心显示类有
// 4.1, DisplayObject => 显示对象基类,所有显示对象均继承自此类
// 4.2, Bitmap => 位图,用来显示图片
// 4.3, Shape => 用来显示矢量图,可以使用其中的方法绘制矢量图形
// 4.4, TextField => 文本类
// 4.5, BitmapText => 位图文本类
// 4.6, DisplayObjectContainer => 显示对象容器接口,所有显示对象容器均实现此接口
// 4.7, Sprite => 带有矢量绘制功能的显示容器
// 4.8, Stage => 舞台类 class Main extends egret.DisplayObjectContainer { // Main 类构造器, 初始化的时候自动执行
// egret.Event.ADDED_TO_STAGE, 在将显示对象添加到舞台显示列表或时调度
public constructor(){
super();
this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
} // 业务逻辑的开始
private onAddToStage(event:egret.Event){
var myGrid:MyGrid = new MyGrid();
this.addChild( myGrid );
}
}

3: 自定义的矢量图显示类 MyGrid.ts

// 自定义显示类都需要继承 8 大显示类中的一个
// 该类就是一个继承了矢量图类的显示类
class MyGrid extends egret.Shape{ // 构造方法, 初始化的时候自动执行
public constructor(){
super();
this.drawGrid();
} // this.graphics 绘图对象, 具体方法看下图
private drawGrid(){
this.graphics.beginFill( 0x0000ff );
this.graphics.drawRect( 0, 0, 50,50 );
this.graphics.endFill();
this.graphics.beginFill( 0x0000ff );
this.graphics.drawRect( 50, 50, 50, 50);
this.graphics.endFill();
this.graphics.beginFill( 0xff0000 );
this.graphics.drawRect( 50, 0, 50,50 );
this.graphics.endFill();
this.graphics.beginFill( 0xff0000 );
this.graphics.drawRect( 0, 50, 50,50 );
this.graphics.endFill();
}
}

4: 绘图对象内置的方法

最新文章

  1. JVM的内存分配与垃圾回收策略
  2. DS Tree 已知后序、中序 => 建树 => 求先序
  3. 深入浅出Redis04使用Redis数据库(lists类型)
  4. 暴力枚举 UVA 10976 Fractions Again?!
  5. 分布式拒绝服务攻击(DDoS)原理及防范
  6. codeforces 431 D. Random Task 组合数学
  7. 学习JSONP
  8. Files to be needed by importing the android application with eclipse
  9. post 提交数据
  10. 关于LINUX各类系统资源整合
  11. Python入门之PyCharm的快捷键与常用设置和扩展(Win系统)
  12. FFmpeg源代码简单分析:libavdevice的gdigrab
  13. css图形——椭圆
  14. 算法笔记 3.2 codeup1935 查找学生信息
  15. POJ 2408 - Anagram Groups - [字典树]
  16. 2017"百度之星"程序设计大赛 - 复赛 01,03,05
  17. flume 1.7在windows下的安装与运行
  18. TensorFlow object detection API应用--配置
  19. Leetcode刷题记录:编码并解码短网址
  20. Redis学习之路(一)之缓存知识体系

热门文章

  1. 将mongo设置为windows的服务
  2. RTB业务知识之2-Impression概念和关键属性
  3. Nexus3.6版私服搭建安装与配置教程
  4. 【ApplicationListener】Springboot各类事件监听器
  5. static link:关于gcc连接静态库的几种方式
  6. 推荐两个小工具MediaInfo 和 netpersec
  7. P1164小A点菜
  8. 改变端口的方法phpstudy
  9. python常用模块: random模块, time模块, sys模块, os模块, 序列化模块
  10. java jdk版本切换