cocos2d-cli 1.6.4 → 2.0.0
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.
- package/data/script_map.json +25 -25
- package/dist/bin/cocos2d-cli.js +64 -0
- package/dist/src/commands/add-component.js +3 -0
- package/dist/src/commands/add.js +3 -0
- package/dist/src/commands/build.js +6 -0
- package/dist/src/commands/create-scene.js +3 -0
- package/dist/src/commands/get.js +3 -0
- package/dist/src/commands/prefab-create.js +109 -0
- package/dist/src/commands/remove-component.js +3 -0
- package/dist/src/commands/remove.js +3 -0
- package/dist/src/commands/screenshot.js +41 -0
- package/dist/src/commands/set-component.js +3 -0
- package/dist/src/commands/set.js +3 -0
- package/dist/src/commands/tree.js +24 -0
- package/{src → dist/src}/lib/cc/CCButton.js +26 -33
- package/{src → dist/src}/lib/cc/CCCamera.js +20 -30
- package/{src → dist/src}/lib/cc/CCCanvas.js +10 -15
- package/{src → dist/src}/lib/cc/CCColor.js +6 -8
- package/{src → dist/src}/lib/cc/CCComponent.js +8 -29
- package/{src → dist/src}/lib/cc/CCLabel.js +44 -51
- package/{src → dist/src}/lib/cc/CCNode.js +52 -118
- package/{src → dist/src}/lib/cc/CCObject.js +4 -8
- package/{src → dist/src}/lib/cc/CCPrefab.js +77 -100
- package/{src → dist/src}/lib/cc/CCRect.js +6 -8
- package/{src → dist/src}/lib/cc/CCRichText.js +10 -16
- package/{src → dist/src}/lib/cc/CCScene.js +3 -13
- package/dist/src/lib/cc/CCSceneAsset.js +242 -0
- package/{src → dist/src}/lib/cc/CCSize.js +4 -8
- package/{src → dist/src}/lib/cc/CCSprite.js +21 -33
- package/{src → dist/src}/lib/cc/CCTrs.js +4 -29
- package/{src → dist/src}/lib/cc/CCVec2.js +4 -8
- package/{src → dist/src}/lib/cc/CCVec3.js +5 -8
- package/{src → dist/src}/lib/cc/CCWidget.js +20 -24
- package/dist/src/lib/fire-utils.js +86 -0
- package/dist/src/lib/json-parser.js +114 -0
- package/dist/src/lib/node-utils.js +131 -0
- package/{src → dist/src}/lib/screenshot-core.js +54 -119
- package/dist/src/lib/templates.js +17 -0
- package/dist/src/lib/utils.js +81 -0
- package/package.json +40 -33
- package/bin/cocos2d-cli.js +0 -152
- package/src/commands/add-component.js +0 -112
- package/src/commands/add.js +0 -177
- package/src/commands/build.js +0 -78
- package/src/commands/create-scene.js +0 -181
- package/src/commands/get.js +0 -108
- package/src/commands/prefab-create.js +0 -111
- package/src/commands/remove-component.js +0 -111
- package/src/commands/remove.js +0 -99
- package/src/commands/screenshot.js +0 -108
- package/src/commands/set-component.js +0 -119
- package/src/commands/set.js +0 -107
- package/src/commands/tree.js +0 -29
- package/src/lib/cc/CCSceneAsset.js +0 -303
- package/src/lib/cc/index.js +0 -42
- package/src/lib/fire-utils.js +0 -374
- package/src/lib/json-parser.js +0 -185
- package/src/lib/node-utils.js +0 -395
- package/src/lib/screenshot/favicon.ico +0 -0
- package/src/lib/screenshot/index.html +0 -30
- package/src/lib/templates.js +0 -49
- package/src/lib/utils.js +0 -202
|
@@ -1,50 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class CCComponent extends CCObject {
|
|
1
|
+
import CCObject from './CCObject.js';
|
|
2
|
+
import { generateId } from '../utils.js';
|
|
3
|
+
export default class CCComponent extends CCObject {
|
|
4
|
+
node;
|
|
5
|
+
_enabled;
|
|
6
|
+
_id;
|
|
8
7
|
constructor() {
|
|
9
8
|
super('');
|
|
10
9
|
this.__type__ = 'cc.Component';
|
|
11
|
-
|
|
12
|
-
// 关联的节点
|
|
13
10
|
this.node = null;
|
|
14
|
-
|
|
15
|
-
// 启用状态
|
|
16
11
|
this._enabled = true;
|
|
17
|
-
|
|
18
|
-
// 唯一标识(22位压缩格式)
|
|
19
12
|
this._id = generateId();
|
|
20
13
|
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* 设置节点引用
|
|
24
|
-
*/
|
|
25
14
|
setNode(nodeIndex) {
|
|
26
15
|
this.node = { __id__: nodeIndex };
|
|
27
16
|
return this;
|
|
28
17
|
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* 获取属性(子类重写)
|
|
32
|
-
*/
|
|
33
18
|
getProp() {
|
|
34
19
|
return {
|
|
35
20
|
class: this.__type__,
|
|
36
21
|
enabled: this._enabled
|
|
37
22
|
};
|
|
38
23
|
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* 设置属性(子类重写)
|
|
42
|
-
*/
|
|
43
24
|
setProp(props) {
|
|
44
|
-
if (props.enabled !== undefined)
|
|
25
|
+
if (props.enabled !== undefined)
|
|
26
|
+
this._enabled = props.enabled;
|
|
45
27
|
return this;
|
|
46
28
|
}
|
|
47
|
-
|
|
48
29
|
toJSON() {
|
|
49
30
|
return {
|
|
50
31
|
__type__: this.__type__,
|
|
@@ -56,5 +37,3 @@ class CCComponent extends CCObject {
|
|
|
56
37
|
};
|
|
57
38
|
}
|
|
58
39
|
}
|
|
59
|
-
|
|
60
|
-
module.exports = CCComponent;
|
|
@@ -1,13 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import CCComponent from './CCComponent.js';
|
|
2
|
+
export default class CCLabel extends CCComponent {
|
|
3
|
+
_materials;
|
|
4
|
+
_srcBlendFactor;
|
|
5
|
+
_dstBlendFactor;
|
|
6
|
+
_string;
|
|
7
|
+
_N$string;
|
|
8
|
+
_fontSize;
|
|
9
|
+
_lineHeight;
|
|
10
|
+
_enableWrapText;
|
|
11
|
+
_N$file;
|
|
12
|
+
_isSystemFontUsed;
|
|
13
|
+
_spacingX;
|
|
14
|
+
_batchAsBitmap;
|
|
15
|
+
_styleFlags;
|
|
16
|
+
_underlineHeight;
|
|
17
|
+
_N$horizontalAlign;
|
|
18
|
+
_N$verticalAlign;
|
|
19
|
+
_N$fontFamily;
|
|
20
|
+
_N$overflow;
|
|
21
|
+
_N$cacheMode;
|
|
7
22
|
constructor() {
|
|
8
23
|
super();
|
|
9
24
|
this.__type__ = 'cc.Label';
|
|
10
|
-
|
|
11
25
|
this._materials = [{ __uuid__: 'eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432' }];
|
|
12
26
|
this._srcBlendFactor = 770;
|
|
13
27
|
this._dstBlendFactor = 771;
|
|
@@ -28,36 +42,20 @@ class CCLabel extends CCComponent {
|
|
|
28
42
|
this._N$overflow = 0;
|
|
29
43
|
this._N$cacheMode = 0;
|
|
30
44
|
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* 设置文本内容
|
|
34
|
-
*/
|
|
35
45
|
setString(str) {
|
|
36
46
|
this._string = str;
|
|
37
47
|
this._N$string = str;
|
|
38
48
|
return this;
|
|
39
49
|
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* 设置字体大小
|
|
43
|
-
*/
|
|
44
50
|
setFontSize(size) {
|
|
45
51
|
this._fontSize = size;
|
|
46
52
|
this._lineHeight = size;
|
|
47
53
|
return this;
|
|
48
54
|
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* 设置字体
|
|
52
|
-
*/
|
|
53
55
|
setFontFamily(family) {
|
|
54
56
|
this._N$fontFamily = family;
|
|
55
57
|
return this;
|
|
56
58
|
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* 获取属性
|
|
60
|
-
*/
|
|
61
59
|
getProp() {
|
|
62
60
|
const H_ALIGN = ['LEFT', 'CENTER', 'RIGHT'];
|
|
63
61
|
const V_ALIGN = ['TOP', 'CENTER', 'BOTTOM'];
|
|
@@ -73,45 +71,42 @@ class CCLabel extends CCComponent {
|
|
|
73
71
|
wrap: this._enableWrapText
|
|
74
72
|
};
|
|
75
73
|
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* 将语义化对齐字符串转为数字
|
|
79
|
-
* horizontalAlign: left=0, center=1, right=2
|
|
80
|
-
* verticalAlign: top=0, center=1, bottom=2
|
|
81
|
-
*/
|
|
82
74
|
static parseHAlign(value) {
|
|
83
|
-
if (typeof value === 'number')
|
|
75
|
+
if (typeof value === 'number')
|
|
76
|
+
return value;
|
|
84
77
|
switch (String(value).toLowerCase()) {
|
|
85
|
-
case 'left':
|
|
78
|
+
case 'left': return 0;
|
|
86
79
|
case 'center': return 1;
|
|
87
|
-
case 'right':
|
|
88
|
-
default:
|
|
80
|
+
case 'right': return 2;
|
|
81
|
+
default: return 1;
|
|
89
82
|
}
|
|
90
83
|
}
|
|
91
|
-
|
|
92
84
|
static parseVAlign(value) {
|
|
93
|
-
if (typeof value === 'number')
|
|
85
|
+
if (typeof value === 'number')
|
|
86
|
+
return value;
|
|
94
87
|
switch (String(value).toLowerCase()) {
|
|
95
|
-
case 'top':
|
|
88
|
+
case 'top': return 0;
|
|
96
89
|
case 'center': return 1;
|
|
97
90
|
case 'bottom': return 2;
|
|
98
|
-
default:
|
|
91
|
+
default: return 1;
|
|
99
92
|
}
|
|
100
93
|
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* 设置属性
|
|
104
|
-
*/
|
|
105
94
|
setProp(props) {
|
|
106
|
-
|
|
107
|
-
if (props.
|
|
108
|
-
|
|
109
|
-
if (props.
|
|
110
|
-
|
|
111
|
-
if (props.
|
|
95
|
+
super.setProp(props);
|
|
96
|
+
if (props.string !== undefined)
|
|
97
|
+
this.setString(props.string);
|
|
98
|
+
if (props.fontSize !== undefined)
|
|
99
|
+
this.setFontSize(props.fontSize);
|
|
100
|
+
if (props.lineHeight !== undefined)
|
|
101
|
+
this._lineHeight = props.lineHeight;
|
|
102
|
+
if (props.fontFamily !== undefined)
|
|
103
|
+
this.setFontFamily(props.fontFamily);
|
|
104
|
+
if (props.horizontalAlign !== undefined)
|
|
105
|
+
this._N$horizontalAlign = CCLabel.parseHAlign(props.horizontalAlign);
|
|
106
|
+
if (props.verticalAlign !== undefined)
|
|
107
|
+
this._N$verticalAlign = CCLabel.parseVAlign(props.verticalAlign);
|
|
112
108
|
return this;
|
|
113
109
|
}
|
|
114
|
-
|
|
115
110
|
toJSON() {
|
|
116
111
|
return {
|
|
117
112
|
__type__: this.__type__,
|
|
@@ -125,7 +120,7 @@ class CCLabel extends CCComponent {
|
|
|
125
120
|
_string: this._string,
|
|
126
121
|
_N$string: this._N$string,
|
|
127
122
|
_fontSize: this._fontSize,
|
|
128
|
-
_lineHeight: this.
|
|
123
|
+
_lineHeight: this._fontSize,
|
|
129
124
|
_enableWrapText: this._enableWrapText,
|
|
130
125
|
_N$file: this._N$file,
|
|
131
126
|
_isSystemFontUsed: this._isSystemFontUsed,
|
|
@@ -142,5 +137,3 @@ class CCLabel extends CCComponent {
|
|
|
142
137
|
};
|
|
143
138
|
}
|
|
144
139
|
}
|
|
145
|
-
|
|
146
|
-
module.exports = CCLabel;
|
|
@@ -1,186 +1,120 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import CCObject from './CCObject.js';
|
|
2
|
+
import CCColor from './CCColor.js';
|
|
3
|
+
import CCSize from './CCSize.js';
|
|
4
|
+
import CCVec2 from './CCVec2.js';
|
|
5
|
+
import CCVec3 from './CCVec3.js';
|
|
6
|
+
import CCTrs from './CCTrs.js';
|
|
7
|
+
export default class CCNode extends CCObject {
|
|
8
|
+
_parent;
|
|
9
|
+
_children;
|
|
10
|
+
_active;
|
|
11
|
+
_components;
|
|
12
|
+
_prefab;
|
|
13
|
+
_opacity;
|
|
14
|
+
_color;
|
|
15
|
+
_contentSize;
|
|
16
|
+
_anchorPoint;
|
|
17
|
+
_trs;
|
|
18
|
+
_eulerAngles;
|
|
19
|
+
_skewX;
|
|
20
|
+
_skewY;
|
|
21
|
+
_is3DNode;
|
|
22
|
+
_groupIndex;
|
|
23
|
+
groupIndex;
|
|
24
|
+
_id;
|
|
12
25
|
constructor(name = 'Node') {
|
|
13
26
|
super(name);
|
|
14
27
|
this.__type__ = 'cc.Node';
|
|
15
|
-
|
|
16
|
-
// 父子关系
|
|
17
28
|
this._parent = null;
|
|
18
29
|
this._children = [];
|
|
19
|
-
|
|
20
|
-
// 激活状态
|
|
21
30
|
this._active = true;
|
|
22
|
-
|
|
23
|
-
// 组件列表
|
|
24
31
|
this._components = [];
|
|
25
|
-
|
|
26
|
-
// 预制体信息
|
|
27
32
|
this._prefab = null;
|
|
28
|
-
|
|
29
|
-
// 显示属性
|
|
30
33
|
this._opacity = 255;
|
|
31
34
|
this._color = new CCColor();
|
|
32
35
|
this._contentSize = new CCSize();
|
|
33
36
|
this._anchorPoint = new CCVec2(0.5, 0.5);
|
|
34
|
-
|
|
35
|
-
// 变换属性
|
|
36
37
|
this._trs = new CCTrs();
|
|
37
38
|
this._eulerAngles = new CCVec3();
|
|
38
39
|
this._skewX = 0;
|
|
39
40
|
this._skewY = 0;
|
|
40
41
|
this._is3DNode = false;
|
|
41
|
-
|
|
42
|
-
// 分组
|
|
43
42
|
this._groupIndex = 0;
|
|
44
43
|
this.groupIndex = 0;
|
|
45
|
-
|
|
46
|
-
// 唯一标识(预制体中为空,场景中生成)
|
|
47
44
|
this._id = '';
|
|
48
45
|
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* 设置 ID
|
|
52
|
-
*/
|
|
53
46
|
setId(id) {
|
|
54
47
|
this._id = id;
|
|
55
48
|
return this;
|
|
56
49
|
}
|
|
57
|
-
|
|
58
|
-
// Position getters/setters
|
|
59
50
|
get x() { return this._trs.x; }
|
|
60
51
|
set x(v) { this._trs.x = v; }
|
|
61
|
-
|
|
62
52
|
get y() { return this._trs.y; }
|
|
63
53
|
set y(v) { this._trs.y = v; }
|
|
64
|
-
|
|
65
|
-
// Scale getters/setters
|
|
66
54
|
get scaleX() { return this._trs.scaleX; }
|
|
67
55
|
set scaleX(v) { this._trs.scaleX = v; }
|
|
68
|
-
|
|
69
56
|
get scaleY() { return this._trs.scaleY; }
|
|
70
57
|
set scaleY(v) { this._trs.scaleY = v; }
|
|
71
|
-
|
|
72
|
-
// Size getters/setters
|
|
73
58
|
get width() { return this._contentSize.width; }
|
|
74
59
|
set width(v) { this._contentSize.width = v; }
|
|
75
|
-
|
|
76
60
|
get height() { return this._contentSize.height; }
|
|
77
61
|
set height(v) { this._contentSize.height = v; }
|
|
78
|
-
|
|
79
|
-
// Anchor getters/setters
|
|
80
62
|
get anchorX() { return this._anchorPoint.x; }
|
|
81
63
|
set anchorX(v) { this._anchorPoint.x = v; }
|
|
82
|
-
|
|
83
64
|
get anchorY() { return this._anchorPoint.y; }
|
|
84
65
|
set anchorY(v) { this._anchorPoint.y = v; }
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* 设置位置
|
|
88
|
-
*/
|
|
89
66
|
setPosition(x, y) {
|
|
90
67
|
this._trs.setPosition(x, y);
|
|
91
68
|
return this;
|
|
92
69
|
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* 设置大小
|
|
96
|
-
*/
|
|
97
70
|
setContentSize(width, height) {
|
|
98
71
|
this._contentSize.set(width, height);
|
|
99
72
|
return this;
|
|
100
73
|
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* 设置锚点
|
|
104
|
-
*/
|
|
105
74
|
setAnchorPoint(x, y) {
|
|
106
75
|
this._anchorPoint.set(x, y);
|
|
107
76
|
return this;
|
|
108
77
|
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* 设置缩放
|
|
112
|
-
*/
|
|
113
78
|
setScale(x, y = x) {
|
|
114
79
|
this._trs.setScale(x, y);
|
|
115
80
|
return this;
|
|
116
81
|
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* 设置旋转(角度)
|
|
120
|
-
*/
|
|
121
82
|
setRotation(angle) {
|
|
122
83
|
this._trs.rotZ = angle * Math.PI / 180;
|
|
123
84
|
this._eulerAngles.z = angle;
|
|
124
85
|
return this;
|
|
125
86
|
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* 设置颜色
|
|
129
|
-
*/
|
|
130
87
|
setColor(r, g, b, a = 255) {
|
|
131
88
|
this._color.set(r, g, b, a);
|
|
132
89
|
return this;
|
|
133
90
|
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* 设置透明度
|
|
137
|
-
*/
|
|
138
91
|
setOpacity(opacity) {
|
|
139
92
|
this._opacity = opacity;
|
|
140
93
|
return this;
|
|
141
94
|
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* 设置激活状态
|
|
145
|
-
*/
|
|
146
95
|
setActive(active) {
|
|
147
96
|
this._active = active;
|
|
148
97
|
return this;
|
|
149
98
|
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* 设置父节点
|
|
153
|
-
* @param {CCNode|number} parent - 父节点对象或索引
|
|
154
|
-
*/
|
|
155
99
|
setParent(parent) {
|
|
156
100
|
this._parent = typeof parent === 'number' ? { __id__: parent } : parent;
|
|
157
101
|
return this;
|
|
158
102
|
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* 添加子节点
|
|
162
|
-
* @param {CCNode|number} child - 子节点对象或索引
|
|
163
|
-
*/
|
|
164
103
|
addChild(child) {
|
|
165
|
-
|
|
104
|
+
const childNode = typeof child === 'number' ? { __id__: child } : child;
|
|
105
|
+
this._children.push(childNode);
|
|
106
|
+
if (typeof childNode !== 'number' && childNode._parent !== undefined) {
|
|
107
|
+
childNode._parent = this;
|
|
108
|
+
}
|
|
166
109
|
return this;
|
|
167
110
|
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* 添加组件
|
|
171
|
-
* @param {CCComponent|number} comp - 组件对象或索引
|
|
172
|
-
*/
|
|
173
111
|
addComponent(comp) {
|
|
174
112
|
this._components.push(typeof comp === 'number' ? { __id__: comp } : comp);
|
|
175
113
|
return this;
|
|
176
114
|
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* 获取属性
|
|
180
|
-
*/
|
|
181
115
|
getProp() {
|
|
182
116
|
const trs = this._trs?.array || [0, 0, 0, 0, 0, 0, 1, 1, 1, 1];
|
|
183
|
-
|
|
117
|
+
return {
|
|
184
118
|
name: this._name,
|
|
185
119
|
active: this._active,
|
|
186
120
|
x: trs[0],
|
|
@@ -195,39 +129,41 @@ class CCNode extends CCObject {
|
|
|
195
129
|
opacity: this._opacity ?? 255,
|
|
196
130
|
color: this._color ? `#${this._color.r.toString(16).padStart(2, '0')}${this._color.g.toString(16).padStart(2, '0')}${this._color.b.toString(16).padStart(2, '0')}` : '#ffffff'
|
|
197
131
|
};
|
|
198
|
-
return result;
|
|
199
132
|
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* 设置属性
|
|
203
|
-
*/
|
|
204
133
|
setProp(props) {
|
|
205
|
-
if (props.name !== undefined)
|
|
206
|
-
|
|
207
|
-
if (props.
|
|
208
|
-
|
|
209
|
-
if (props.
|
|
210
|
-
|
|
211
|
-
if (props.
|
|
212
|
-
|
|
213
|
-
if (props.
|
|
214
|
-
|
|
134
|
+
if (props.name !== undefined)
|
|
135
|
+
this._name = props.name;
|
|
136
|
+
if (props.active !== undefined)
|
|
137
|
+
this._active = props.active;
|
|
138
|
+
if (props.x !== undefined)
|
|
139
|
+
this._trs.array[0] = props.x;
|
|
140
|
+
if (props.y !== undefined)
|
|
141
|
+
this._trs.array[1] = props.y;
|
|
142
|
+
if (props.width !== undefined)
|
|
143
|
+
this._contentSize.width = props.width;
|
|
144
|
+
if (props.height !== undefined)
|
|
145
|
+
this._contentSize.height = props.height;
|
|
146
|
+
if (props.anchorX !== undefined)
|
|
147
|
+
this._anchorPoint.x = props.anchorX;
|
|
148
|
+
if (props.anchorY !== undefined)
|
|
149
|
+
this._anchorPoint.y = props.anchorY;
|
|
150
|
+
if (props.scaleX !== undefined)
|
|
151
|
+
this._trs.array[7] = props.scaleX;
|
|
152
|
+
if (props.scaleY !== undefined)
|
|
153
|
+
this._trs.array[8] = props.scaleY;
|
|
215
154
|
if (props.rotation !== undefined) {
|
|
216
155
|
this._trs.array[5] = props.rotation * Math.PI / 180;
|
|
217
156
|
this._eulerAngles.z = props.rotation;
|
|
218
157
|
}
|
|
219
|
-
if (props.opacity !== undefined)
|
|
158
|
+
if (props.opacity !== undefined)
|
|
159
|
+
this._opacity = props.opacity;
|
|
220
160
|
return this;
|
|
221
161
|
}
|
|
222
|
-
|
|
223
162
|
toJSON(indexMap) {
|
|
224
|
-
// 处理引用
|
|
225
163
|
const parent = this._parent ? (indexMap ? { __id__: indexMap.get(this._parent) } : this._parent) : null;
|
|
226
164
|
const children = indexMap ? this._children.map(c => ({ __id__: indexMap.get(c) })) : this._children;
|
|
227
165
|
const components = indexMap ? this._components.map(c => ({ __id__: indexMap.get(c) })) : this._components;
|
|
228
166
|
const prefab = this._prefab ? (indexMap ? { __id__: indexMap.get(this._prefab) } : this._prefab) : null;
|
|
229
|
-
|
|
230
|
-
// 显式控制属性顺序
|
|
231
167
|
return {
|
|
232
168
|
__type__: this.__type__,
|
|
233
169
|
_name: this._name,
|
|
@@ -252,5 +188,3 @@ class CCNode extends CCObject {
|
|
|
252
188
|
};
|
|
253
189
|
}
|
|
254
190
|
}
|
|
255
|
-
|
|
256
|
-
module.exports = CCNode;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export default class CCObject {
|
|
2
|
+
__type__;
|
|
3
|
+
_name;
|
|
4
|
+
_objFlags;
|
|
5
5
|
constructor(name = '') {
|
|
6
6
|
this.__type__ = '';
|
|
7
7
|
this._name = name;
|
|
8
8
|
this._objFlags = 0;
|
|
9
9
|
}
|
|
10
|
-
|
|
11
10
|
toJSON() {
|
|
12
11
|
const obj = { ...this };
|
|
13
|
-
// 移除 undefined 的属性
|
|
14
12
|
for (const key in obj) {
|
|
15
13
|
if (obj[key] === undefined) {
|
|
16
14
|
delete obj[key];
|
|
@@ -19,5 +17,3 @@ class CCObject {
|
|
|
19
17
|
return obj;
|
|
20
18
|
}
|
|
21
19
|
}
|
|
22
|
-
|
|
23
|
-
module.exports = CCObject;
|