cocos2d-cli 1.6.3 → 1.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/bin/cocos2d-cli.js +152 -152
  2. package/data/script_map.json +25 -25
  3. package/package.json +33 -33
  4. package/src/commands/add-component.js +112 -112
  5. package/src/commands/add.js +177 -177
  6. package/src/commands/build.js +78 -78
  7. package/src/commands/create-scene.js +181 -181
  8. package/src/commands/get.js +108 -108
  9. package/src/commands/prefab-create.js +110 -110
  10. package/src/commands/remove-component.js +110 -110
  11. package/src/commands/remove.js +99 -99
  12. package/src/commands/screenshot.js +108 -103
  13. package/src/commands/set-component.js +119 -119
  14. package/src/commands/set.js +107 -107
  15. package/src/commands/tree.js +28 -28
  16. package/src/lib/cc/CCButton.js +122 -122
  17. package/src/lib/cc/CCCamera.js +93 -93
  18. package/src/lib/cc/CCCanvas.js +54 -54
  19. package/src/lib/cc/CCColor.js +32 -32
  20. package/src/lib/cc/CCComponent.js +60 -60
  21. package/src/lib/cc/CCLabel.js +146 -146
  22. package/src/lib/cc/CCNode.js +255 -255
  23. package/src/lib/cc/CCObject.js +23 -23
  24. package/src/lib/cc/CCPrefab.js +242 -242
  25. package/src/lib/cc/CCRect.js +32 -32
  26. package/src/lib/cc/CCRichText.js +44 -44
  27. package/src/lib/cc/CCScene.js +42 -42
  28. package/src/lib/cc/CCSceneAsset.js +302 -302
  29. package/src/lib/cc/CCSize.js +26 -26
  30. package/src/lib/cc/CCSprite.js +94 -94
  31. package/src/lib/cc/CCTrs.js +74 -74
  32. package/src/lib/cc/CCVec2.js +26 -26
  33. package/src/lib/cc/CCVec3.js +29 -29
  34. package/src/lib/cc/CCWidget.js +98 -98
  35. package/src/lib/cc/index.js +42 -42
  36. package/src/lib/fire-utils.js +373 -373
  37. package/src/lib/json-parser.js +185 -185
  38. package/src/lib/node-utils.js +395 -395
  39. package/src/lib/screenshot/index.html +29 -29
  40. package/src/lib/screenshot-core.js +285 -286
  41. package/src/lib/templates.js +49 -49
  42. package/src/lib/utils.js +202 -202
@@ -1,94 +1,94 @@
1
- const CCComponent = require('./CCComponent');
2
- const CCVec2 = require('./CCVec2');
3
-
4
- const default_sprite_splash = 'a23235d1-15db-4b95-8439-a2e005bfff91';
5
-
6
- /**
7
- * Cocos Creator Sprite 组件
8
- */
9
- class CCSprite extends CCComponent {
10
- constructor() {
11
- super();
12
- this.__type__ = 'cc.Sprite';
13
-
14
- this._materials = [{ __uuid__: 'eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432' }];
15
- this._srcBlendFactor = 770;
16
- this._dstBlendFactor = 771;
17
- this._spriteFrame = null;
18
- this._type = 0;
19
- this._sizeMode = 0;
20
- this._fillType = 0;
21
- this._fillCenter = new CCVec2();
22
- this._fillStart = 0;
23
- this._fillRange = 0;
24
- this._isTrimmedMode = true;
25
- this._atlas = null;
26
-
27
- this.setSpriteFrame(default_sprite_splash);
28
- }
29
-
30
- /**
31
- * 设置精灵帧
32
- */
33
- setSpriteFrame(uuid) {
34
- this._spriteFrame = { __uuid__: uuid };
35
- return this;
36
- }
37
-
38
- /**
39
- * 设置尺寸模式
40
- * 0: CUSTOM, 1: TRIMMED, 2: RAW
41
- */
42
- setSizeMode(mode) {
43
- this._sizeMode = mode;
44
- return this;
45
- }
46
-
47
- /**
48
- * 获取属性
49
- */
50
- getProp() {
51
- const SIZE_MODE = ['CUSTOM', 'RAW', 'TRIMMED'];
52
- const SPRITE_TYPE = ['SIMPLE', 'SLICED', 'TILED', 'FILLED', 'MESH'];
53
- return {
54
- sizeMode: SIZE_MODE[this._sizeMode] || this._sizeMode,
55
- type: SPRITE_TYPE[this._type] || this._type,
56
- trim: this._isTrimmedMode
57
- };
58
- }
59
-
60
- /**
61
- * 设置属性
62
- */
63
- setProp(props) {
64
- if (props.sizeMode !== undefined) this.setSizeMode(props.sizeMode);
65
- if (props.spriteFrame !== undefined) this.setSpriteFrame(props.spriteFrame);
66
- if (props.type !== undefined) this._type = props.type;
67
- return this;
68
- }
69
-
70
- toJSON() {
71
- return {
72
- __type__: this.__type__,
73
- _name: this._name,
74
- _objFlags: this._objFlags,
75
- node: this.node,
76
- _enabled: this._enabled,
77
- _materials: this._materials,
78
- _srcBlendFactor: this._srcBlendFactor,
79
- _dstBlendFactor: this._dstBlendFactor,
80
- _spriteFrame: this._spriteFrame,
81
- _type: this._type,
82
- _sizeMode: this._sizeMode,
83
- _fillType: this._fillType,
84
- _fillCenter: this._fillCenter.toJSON(),
85
- _fillStart: this._fillStart,
86
- _fillRange: this._fillRange,
87
- _isTrimmedMode: this._isTrimmedMode,
88
- _atlas: this._atlas,
89
- _id: this._id
90
- };
91
- }
92
- }
93
-
94
- module.exports = CCSprite;
1
+ const CCComponent = require('./CCComponent');
2
+ const CCVec2 = require('./CCVec2');
3
+
4
+ const default_sprite_splash = 'a23235d1-15db-4b95-8439-a2e005bfff91';
5
+
6
+ /**
7
+ * Cocos Creator Sprite 组件
8
+ */
9
+ class CCSprite extends CCComponent {
10
+ constructor() {
11
+ super();
12
+ this.__type__ = 'cc.Sprite';
13
+
14
+ this._materials = [{ __uuid__: 'eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432' }];
15
+ this._srcBlendFactor = 770;
16
+ this._dstBlendFactor = 771;
17
+ this._spriteFrame = null;
18
+ this._type = 0;
19
+ this._sizeMode = 0;
20
+ this._fillType = 0;
21
+ this._fillCenter = new CCVec2();
22
+ this._fillStart = 0;
23
+ this._fillRange = 0;
24
+ this._isTrimmedMode = true;
25
+ this._atlas = null;
26
+
27
+ this.setSpriteFrame(default_sprite_splash);
28
+ }
29
+
30
+ /**
31
+ * 设置精灵帧
32
+ */
33
+ setSpriteFrame(uuid) {
34
+ this._spriteFrame = { __uuid__: uuid };
35
+ return this;
36
+ }
37
+
38
+ /**
39
+ * 设置尺寸模式
40
+ * 0: CUSTOM, 1: TRIMMED, 2: RAW
41
+ */
42
+ setSizeMode(mode) {
43
+ this._sizeMode = mode;
44
+ return this;
45
+ }
46
+
47
+ /**
48
+ * 获取属性
49
+ */
50
+ getProp() {
51
+ const SIZE_MODE = ['CUSTOM', 'RAW', 'TRIMMED'];
52
+ const SPRITE_TYPE = ['SIMPLE', 'SLICED', 'TILED', 'FILLED', 'MESH'];
53
+ return {
54
+ sizeMode: SIZE_MODE[this._sizeMode] || this._sizeMode,
55
+ type: SPRITE_TYPE[this._type] || this._type,
56
+ trim: this._isTrimmedMode
57
+ };
58
+ }
59
+
60
+ /**
61
+ * 设置属性
62
+ */
63
+ setProp(props) {
64
+ if (props.sizeMode !== undefined) this.setSizeMode(props.sizeMode);
65
+ if (props.spriteFrame !== undefined) this.setSpriteFrame(props.spriteFrame);
66
+ if (props.type !== undefined) this._type = props.type;
67
+ return this;
68
+ }
69
+
70
+ toJSON() {
71
+ return {
72
+ __type__: this.__type__,
73
+ _name: this._name,
74
+ _objFlags: this._objFlags,
75
+ node: this.node,
76
+ _enabled: this._enabled,
77
+ _materials: this._materials,
78
+ _srcBlendFactor: this._srcBlendFactor,
79
+ _dstBlendFactor: this._dstBlendFactor,
80
+ _spriteFrame: this._spriteFrame,
81
+ _type: this._type,
82
+ _sizeMode: this._sizeMode,
83
+ _fillType: this._fillType,
84
+ _fillCenter: this._fillCenter.toJSON(),
85
+ _fillStart: this._fillStart,
86
+ _fillRange: this._fillRange,
87
+ _isTrimmedMode: this._isTrimmedMode,
88
+ _atlas: this._atlas,
89
+ _id: this._id
90
+ };
91
+ }
92
+ }
93
+
94
+ module.exports = CCSprite;
@@ -1,74 +1,74 @@
1
- /**
2
- * Cocos Creator 变换数据类 (TRS = Translation, Rotation, Scale)
3
- * array: [posX, posY, posZ, rotX, rotY, rotZ, rotW, scaleX, scaleY, scaleZ]
4
- */
5
- class CCTrs {
6
- constructor() {
7
- this.__type__ = 'TypedArray';
8
- this.ctor = 'Float64Array';
9
- this.array = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1];
10
- }
11
-
12
- // Position
13
- get x() { return this.array[0]; }
14
- set x(v) { this.array[0] = v; }
15
-
16
- get y() { return this.array[1]; }
17
- set y(v) { this.array[1] = v; }
18
-
19
- get z() { return this.array[2]; }
20
- set z(v) { this.array[2] = v; }
21
-
22
- // Scale
23
- get scaleX() { return this.array[7]; }
24
- set scaleX(v) { this.array[7] = v; }
25
-
26
- get scaleY() { return this.array[8]; }
27
- set scaleY(v) { this.array[8] = v; }
28
-
29
- get scaleZ() { return this.array[9]; }
30
- set scaleZ(v) { this.array[9] = v; }
31
-
32
- // Rotation (四元数)
33
- get rotX() { return this.array[3]; }
34
- set rotX(v) { this.array[3] = v; }
35
-
36
- get rotY() { return this.array[4]; }
37
- set rotY(v) { this.array[4] = v; }
38
-
39
- get rotZ() { return this.array[5]; }
40
- set rotZ(v) { this.array[5] = v; }
41
-
42
- get rotW() { return this.array[6]; }
43
- set rotW(v) { this.array[6] = v; }
44
-
45
- /**
46
- * 设置位置
47
- */
48
- setPosition(x, y, z = 0) {
49
- this.array[0] = x;
50
- this.array[1] = y;
51
- this.array[2] = z;
52
- return this;
53
- }
54
-
55
- /**
56
- * 设置缩放
57
- */
58
- setScale(x, y = x, z = 1) {
59
- this.array[7] = x;
60
- this.array[8] = y;
61
- this.array[9] = z;
62
- return this;
63
- }
64
-
65
- toJSON() {
66
- return {
67
- __type__: this.__type__,
68
- ctor: this.ctor,
69
- array: [...this.array]
70
- };
71
- }
72
- }
73
-
74
- module.exports = CCTrs;
1
+ /**
2
+ * Cocos Creator 变换数据类 (TRS = Translation, Rotation, Scale)
3
+ * array: [posX, posY, posZ, rotX, rotY, rotZ, rotW, scaleX, scaleY, scaleZ]
4
+ */
5
+ class CCTrs {
6
+ constructor() {
7
+ this.__type__ = 'TypedArray';
8
+ this.ctor = 'Float64Array';
9
+ this.array = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1];
10
+ }
11
+
12
+ // Position
13
+ get x() { return this.array[0]; }
14
+ set x(v) { this.array[0] = v; }
15
+
16
+ get y() { return this.array[1]; }
17
+ set y(v) { this.array[1] = v; }
18
+
19
+ get z() { return this.array[2]; }
20
+ set z(v) { this.array[2] = v; }
21
+
22
+ // Scale
23
+ get scaleX() { return this.array[7]; }
24
+ set scaleX(v) { this.array[7] = v; }
25
+
26
+ get scaleY() { return this.array[8]; }
27
+ set scaleY(v) { this.array[8] = v; }
28
+
29
+ get scaleZ() { return this.array[9]; }
30
+ set scaleZ(v) { this.array[9] = v; }
31
+
32
+ // Rotation (四元数)
33
+ get rotX() { return this.array[3]; }
34
+ set rotX(v) { this.array[3] = v; }
35
+
36
+ get rotY() { return this.array[4]; }
37
+ set rotY(v) { this.array[4] = v; }
38
+
39
+ get rotZ() { return this.array[5]; }
40
+ set rotZ(v) { this.array[5] = v; }
41
+
42
+ get rotW() { return this.array[6]; }
43
+ set rotW(v) { this.array[6] = v; }
44
+
45
+ /**
46
+ * 设置位置
47
+ */
48
+ setPosition(x, y, z = 0) {
49
+ this.array[0] = x;
50
+ this.array[1] = y;
51
+ this.array[2] = z;
52
+ return this;
53
+ }
54
+
55
+ /**
56
+ * 设置缩放
57
+ */
58
+ setScale(x, y = x, z = 1) {
59
+ this.array[7] = x;
60
+ this.array[8] = y;
61
+ this.array[9] = z;
62
+ return this;
63
+ }
64
+
65
+ toJSON() {
66
+ return {
67
+ __type__: this.__type__,
68
+ ctor: this.ctor,
69
+ array: [...this.array]
70
+ };
71
+ }
72
+ }
73
+
74
+ module.exports = CCTrs;
@@ -1,26 +1,26 @@
1
- /**
2
- * Cocos Creator 二维向量类
3
- */
4
- class CCVec2 {
5
- constructor(x = 0, y = 0) {
6
- this.__type__ = 'cc.Vec2';
7
- this.x = x;
8
- this.y = y;
9
- }
10
-
11
- set(x, y) {
12
- this.x = x;
13
- this.y = y;
14
- return this;
15
- }
16
-
17
- toJSON() {
18
- return {
19
- __type__: this.__type__,
20
- x: this.x,
21
- y: this.y
22
- };
23
- }
24
- }
25
-
26
- module.exports = CCVec2;
1
+ /**
2
+ * Cocos Creator 二维向量类
3
+ */
4
+ class CCVec2 {
5
+ constructor(x = 0, y = 0) {
6
+ this.__type__ = 'cc.Vec2';
7
+ this.x = x;
8
+ this.y = y;
9
+ }
10
+
11
+ set(x, y) {
12
+ this.x = x;
13
+ this.y = y;
14
+ return this;
15
+ }
16
+
17
+ toJSON() {
18
+ return {
19
+ __type__: this.__type__,
20
+ x: this.x,
21
+ y: this.y
22
+ };
23
+ }
24
+ }
25
+
26
+ module.exports = CCVec2;
@@ -1,29 +1,29 @@
1
- /**
2
- * Cocos Creator 三维向量类
3
- */
4
- class CCVec3 {
5
- constructor(x = 0, y = 0, z = 0) {
6
- this.__type__ = 'cc.Vec3';
7
- this.x = x;
8
- this.y = y;
9
- this.z = z;
10
- }
11
-
12
- set(x, y, z = 0) {
13
- this.x = x;
14
- this.y = y;
15
- this.z = z;
16
- return this;
17
- }
18
-
19
- toJSON() {
20
- return {
21
- __type__: this.__type__,
22
- x: this.x,
23
- y: this.y,
24
- z: this.z
25
- };
26
- }
27
- }
28
-
29
- module.exports = CCVec3;
1
+ /**
2
+ * Cocos Creator 三维向量类
3
+ */
4
+ class CCVec3 {
5
+ constructor(x = 0, y = 0, z = 0) {
6
+ this.__type__ = 'cc.Vec3';
7
+ this.x = x;
8
+ this.y = y;
9
+ this.z = z;
10
+ }
11
+
12
+ set(x, y, z = 0) {
13
+ this.x = x;
14
+ this.y = y;
15
+ this.z = z;
16
+ return this;
17
+ }
18
+
19
+ toJSON() {
20
+ return {
21
+ __type__: this.__type__,
22
+ x: this.x,
23
+ y: this.y,
24
+ z: this.z
25
+ };
26
+ }
27
+ }
28
+
29
+ module.exports = CCVec3;
@@ -1,98 +1,98 @@
1
- const CCComponent = require('./CCComponent');
2
-
3
- /**
4
- * Cocos Creator Widget 组件
5
- */
6
- class CCWidget extends CCComponent {
7
- constructor() {
8
- super();
9
- this.__type__ = 'cc.Widget';
10
-
11
- this.alignMode = 1;
12
- this._target = null;
13
- this._alignFlags = 45;
14
- this._left = 0;
15
- this._right = 0;
16
- this._top = 0;
17
- this._bottom = 0;
18
- this._verticalCenter = 0;
19
- this._horizontalCenter = 0;
20
- this._isAbsLeft = true;
21
- this._isAbsRight = true;
22
- this._isAbsTop = true;
23
- this._isAbsBottom = true;
24
- this._isAbsHorizontalCenter = true;
25
- this._isAbsVerticalCenter = true;
26
- this._originalWidth = 0;
27
- this._originalHeight = 0;
28
- }
29
-
30
- /**
31
- * 设置对齐标志
32
- * 45 = 左 + 右 + 上 + 下 (全对齐)
33
- */
34
- setAlignFlags(flags) {
35
- this._alignFlags = flags;
36
- return this;
37
- }
38
-
39
- /**
40
- * 设置边距
41
- */
42
- setMargins(left, right, top, bottom) {
43
- this._left = left;
44
- this._right = right;
45
- this._top = top;
46
- this._bottom = bottom;
47
- return this;
48
- }
49
-
50
- /**
51
- * 转换为属性面板显示格式
52
- */
53
- toPanelJSON() {
54
- return {
55
- ...super.toPanelJSON(),
56
- top: this._top,
57
- bottom: this._bottom,
58
- left: this._left,
59
- right: this._right,
60
- horizontalCenter: this._horizontalCenter,
61
- verticalCenter: this._verticalCenter,
62
- isAbsLeft: this._isAbsLeft,
63
- isAbsRight: this._isAbsRight,
64
- isAbsTop: this._isAbsTop,
65
- isAbsBottom: this._isAbsBottom
66
- };
67
- }
68
-
69
- toJSON() {
70
- return {
71
- __type__: this.__type__,
72
- _name: this._name,
73
- _objFlags: this._objFlags,
74
- node: this.node,
75
- _enabled: this._enabled,
76
- alignMode: this.alignMode,
77
- _target: this._target,
78
- _alignFlags: this._alignFlags,
79
- _left: this._left,
80
- _right: this._right,
81
- _top: this._top,
82
- _bottom: this._bottom,
83
- _verticalCenter: this._verticalCenter,
84
- _horizontalCenter: this._horizontalCenter,
85
- _isAbsLeft: this._isAbsLeft,
86
- _isAbsRight: this._isAbsRight,
87
- _isAbsTop: this._isAbsTop,
88
- _isAbsBottom: this._isAbsBottom,
89
- _isAbsHorizontalCenter: this._isAbsHorizontalCenter,
90
- _isAbsVerticalCenter: this._isAbsVerticalCenter,
91
- _originalWidth: this._originalWidth,
92
- _originalHeight: this._originalHeight,
93
- _id: this._id
94
- };
95
- }
96
- }
97
-
98
- module.exports = CCWidget;
1
+ const CCComponent = require('./CCComponent');
2
+
3
+ /**
4
+ * Cocos Creator Widget 组件
5
+ */
6
+ class CCWidget extends CCComponent {
7
+ constructor() {
8
+ super();
9
+ this.__type__ = 'cc.Widget';
10
+
11
+ this.alignMode = 1;
12
+ this._target = null;
13
+ this._alignFlags = 45;
14
+ this._left = 0;
15
+ this._right = 0;
16
+ this._top = 0;
17
+ this._bottom = 0;
18
+ this._verticalCenter = 0;
19
+ this._horizontalCenter = 0;
20
+ this._isAbsLeft = true;
21
+ this._isAbsRight = true;
22
+ this._isAbsTop = true;
23
+ this._isAbsBottom = true;
24
+ this._isAbsHorizontalCenter = true;
25
+ this._isAbsVerticalCenter = true;
26
+ this._originalWidth = 0;
27
+ this._originalHeight = 0;
28
+ }
29
+
30
+ /**
31
+ * 设置对齐标志
32
+ * 45 = 左 + 右 + 上 + 下 (全对齐)
33
+ */
34
+ setAlignFlags(flags) {
35
+ this._alignFlags = flags;
36
+ return this;
37
+ }
38
+
39
+ /**
40
+ * 设置边距
41
+ */
42
+ setMargins(left, right, top, bottom) {
43
+ this._left = left;
44
+ this._right = right;
45
+ this._top = top;
46
+ this._bottom = bottom;
47
+ return this;
48
+ }
49
+
50
+ /**
51
+ * 转换为属性面板显示格式
52
+ */
53
+ toPanelJSON() {
54
+ return {
55
+ ...super.toPanelJSON(),
56
+ top: this._top,
57
+ bottom: this._bottom,
58
+ left: this._left,
59
+ right: this._right,
60
+ horizontalCenter: this._horizontalCenter,
61
+ verticalCenter: this._verticalCenter,
62
+ isAbsLeft: this._isAbsLeft,
63
+ isAbsRight: this._isAbsRight,
64
+ isAbsTop: this._isAbsTop,
65
+ isAbsBottom: this._isAbsBottom
66
+ };
67
+ }
68
+
69
+ toJSON() {
70
+ return {
71
+ __type__: this.__type__,
72
+ _name: this._name,
73
+ _objFlags: this._objFlags,
74
+ node: this.node,
75
+ _enabled: this._enabled,
76
+ alignMode: this.alignMode,
77
+ _target: this._target,
78
+ _alignFlags: this._alignFlags,
79
+ _left: this._left,
80
+ _right: this._right,
81
+ _top: this._top,
82
+ _bottom: this._bottom,
83
+ _verticalCenter: this._verticalCenter,
84
+ _horizontalCenter: this._horizontalCenter,
85
+ _isAbsLeft: this._isAbsLeft,
86
+ _isAbsRight: this._isAbsRight,
87
+ _isAbsTop: this._isAbsTop,
88
+ _isAbsBottom: this._isAbsBottom,
89
+ _isAbsHorizontalCenter: this._isAbsHorizontalCenter,
90
+ _isAbsVerticalCenter: this._isAbsVerticalCenter,
91
+ _originalWidth: this._originalWidth,
92
+ _originalHeight: this._originalHeight,
93
+ _id: this._id
94
+ };
95
+ }
96
+ }
97
+
98
+ module.exports = CCWidget;