夜间模式
CreateJS 笔记
A suite of Javascript libraries & tools for building rich, interactive experiences with HTML5.
EaselJS
http://www.createjs.cc/src/docs/easeljs/classes/EaselJS.html
绘制矢量图形
javascript
var graphics = new createjs.Graphics().beginFill("#ff0000").drawRect(0, 0, 100, 100);
var shape = new createjs.Shape(graphics);
// 交替使用也可以使用 Shape 类的图形属性渲染上面一样。
var shape = new createjs.Shape();
shape.graphics.beginFill("#ff0000").drawRect(0, 0, 100, 100);
var graphics = new createjs.Graphics().beginFill("#ff0000").drawRect(0, 0, 100, 100);
var shape = new createjs.Shape(graphics);
// 交替使用也可以使用 Shape 类的图形属性渲染上面一样。
var shape = new createjs.Shape();
shape.graphics.beginFill("#ff0000").drawRect(0, 0, 100, 100);
蒙版
xxx.mask = shape
可以以 shape 的区域建立蒙版
层级
EaselJS 中没有类似 CSS 中的 z-index
概念,可以通过 Container
的方法设置 child
的 index
。
javascript
getChildIndex(child);
setChildIndex(child, index);
getChildIndex(child);
setChildIndex(child, index);
获取图形边界
javascript
var b = xxx.getBounds();
var b = xxx.getBounds();
可以获得 b.x
, b.y
, b.width
, b.height
预加载(preload)
javascript
var queue = new createjs.LoadQueue();
queue.on("complete", handleComplete, this);
queue.on("progress", handleProgress, this);
queue.installPlugin(createjs.Sound);
queue.loadManifest(resList);
var queue = new createjs.LoadQueue();
queue.on("complete", handleComplete, this);
queue.on("progress", handleProgress, this);
queue.installPlugin(createjs.Sound);
queue.loadManifest(resList);
声音(sound)
javascript
// 这里 audio 是 preload 中自定义的名字
var bgm = createjs.Sound.play("audio");
bgm.on(
"complete",
function () {
bgm.play();
},
this
);
// 这里 audio 是 preload 中自定义的名字
var bgm = createjs.Sound.play("audio");
bgm.on(
"complete",
function () {
bgm.play();
},
this
);