cocos2d-cli 1.6.5 → 2.1.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 +115 -122
- package/{src → dist/src}/lib/cc/CCCamera.js +83 -93
- package/{src → dist/src}/lib/cc/CCCanvas.js +49 -54
- package/{src → dist/src}/lib/cc/CCColor.js +30 -32
- package/{src → dist/src}/lib/cc/CCComponent.js +39 -60
- package/{src → dist/src}/lib/cc/CCLabel.js +139 -146
- package/{src → dist/src}/lib/cc/CCNode.js +190 -256
- package/{src → dist/src}/lib/cc/CCObject.js +19 -23
- package/{src → dist/src}/lib/cc/CCPrefab.js +219 -242
- package/{src → dist/src}/lib/cc/CCRect.js +30 -32
- package/{src → dist/src}/lib/cc/CCRichText.js +38 -44
- package/{src → dist/src}/lib/cc/CCScene.js +32 -42
- package/dist/src/lib/cc/CCSceneAsset.js +242 -0
- package/{src → dist/src}/lib/cc/CCSize.js +22 -26
- package/{src → dist/src}/lib/cc/CCSprite.js +82 -94
- package/{src → dist/src}/lib/cc/CCTrs.js +49 -74
- package/{src → dist/src}/lib/cc/CCVec2.js +22 -26
- package/{src → dist/src}/lib/cc/CCVec3.js +26 -29
- package/{src → dist/src}/lib/cc/CCWidget.js +94 -98
- 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 +242 -285
- 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,42 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
_is3DNode: this._is3DNode,
|
|
34
|
-
_groupIndex: this._groupIndex,
|
|
35
|
-
groupIndex: this.groupIndex,
|
|
36
|
-
autoReleaseAssets: this.autoReleaseAssets,
|
|
37
|
-
_id: this._id
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
module.exports = CCScene;
|
|
1
|
+
import CCNode from './CCNode.js';
|
|
2
|
+
export default class CCScene extends CCNode {
|
|
3
|
+
autoReleaseAssets;
|
|
4
|
+
constructor(name = 'NewScene') {
|
|
5
|
+
super(name);
|
|
6
|
+
this.__type__ = 'cc.Scene';
|
|
7
|
+
this._is3DNode = true;
|
|
8
|
+
this._anchorPoint.set(0, 0);
|
|
9
|
+
this.autoReleaseAssets = false;
|
|
10
|
+
}
|
|
11
|
+
toJSON() {
|
|
12
|
+
return {
|
|
13
|
+
__type__: this.__type__,
|
|
14
|
+
_objFlags: this._objFlags,
|
|
15
|
+
_parent: this._parent,
|
|
16
|
+
_children: this._children,
|
|
17
|
+
_active: this._active,
|
|
18
|
+
_components: this._components,
|
|
19
|
+
_prefab: this._prefab,
|
|
20
|
+
_opacity: this._opacity,
|
|
21
|
+
_color: this._color.toJSON(),
|
|
22
|
+
_contentSize: this._contentSize.toJSON(),
|
|
23
|
+
_anchorPoint: this._anchorPoint.toJSON(),
|
|
24
|
+
_trs: this._trs.toJSON(),
|
|
25
|
+
_is3DNode: this._is3DNode,
|
|
26
|
+
_groupIndex: this._groupIndex,
|
|
27
|
+
groupIndex: this.groupIndex,
|
|
28
|
+
autoReleaseAssets: this.autoReleaseAssets,
|
|
29
|
+
_id: this._id
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import CCObject from './CCObject.js';
|
|
2
|
+
import CCScene from './CCScene.js';
|
|
3
|
+
import CCNode from './CCNode.js';
|
|
4
|
+
import CCCanvas from './CCCanvas.js';
|
|
5
|
+
import CCWidget from './CCWidget.js';
|
|
6
|
+
import CCSprite from './CCSprite.js';
|
|
7
|
+
import CCLabel from './CCLabel.js';
|
|
8
|
+
import CCButton from './CCButton.js';
|
|
9
|
+
import CCCamera from './CCCamera.js';
|
|
10
|
+
import { generateCompressedUUID } from '../utils.js';
|
|
11
|
+
export default class CCSceneAsset extends CCObject {
|
|
12
|
+
_native;
|
|
13
|
+
_scene;
|
|
14
|
+
constructor() {
|
|
15
|
+
super('');
|
|
16
|
+
this.__type__ = 'cc.SceneAsset';
|
|
17
|
+
this._native = '';
|
|
18
|
+
this._scene = null;
|
|
19
|
+
}
|
|
20
|
+
getScene() {
|
|
21
|
+
return this._scene;
|
|
22
|
+
}
|
|
23
|
+
addNode(node) {
|
|
24
|
+
if (!this._scene)
|
|
25
|
+
return null;
|
|
26
|
+
node._parent = { __id__: 1 };
|
|
27
|
+
if (!this._scene._children)
|
|
28
|
+
this._scene._children = [];
|
|
29
|
+
this._scene._children.push({ __id__: 0 });
|
|
30
|
+
node._id = generateCompressedUUID();
|
|
31
|
+
return node;
|
|
32
|
+
}
|
|
33
|
+
removeNode(node) {
|
|
34
|
+
if (!node._parent)
|
|
35
|
+
return false;
|
|
36
|
+
const idx = -1;
|
|
37
|
+
if (idx > -1) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
static fromJSON(json) {
|
|
43
|
+
const asset = new CCSceneAsset();
|
|
44
|
+
const objects = [];
|
|
45
|
+
json.forEach((item, index) => {
|
|
46
|
+
objects[index] = createObject(item);
|
|
47
|
+
});
|
|
48
|
+
json.forEach((item, index) => {
|
|
49
|
+
setupReferences(objects[index], item, objects);
|
|
50
|
+
});
|
|
51
|
+
asset._scene = objects[1];
|
|
52
|
+
return asset;
|
|
53
|
+
}
|
|
54
|
+
toJSON() {
|
|
55
|
+
const result = [];
|
|
56
|
+
const indexMap = new Map();
|
|
57
|
+
indexMap.set(this, 0);
|
|
58
|
+
result.push({
|
|
59
|
+
__type__: 'cc.SceneAsset',
|
|
60
|
+
_name: '',
|
|
61
|
+
_objFlags: 0,
|
|
62
|
+
_native: '',
|
|
63
|
+
scene: { __id__: 1 }
|
|
64
|
+
});
|
|
65
|
+
if (this._scene) {
|
|
66
|
+
indexMap.set(this._scene, 1);
|
|
67
|
+
}
|
|
68
|
+
result.push(null);
|
|
69
|
+
const processNode = (node) => {
|
|
70
|
+
if (!node)
|
|
71
|
+
return;
|
|
72
|
+
indexMap.set(node, result.length);
|
|
73
|
+
result.push(null);
|
|
74
|
+
if (node._children) {
|
|
75
|
+
node._children.forEach(child => processNode(child));
|
|
76
|
+
}
|
|
77
|
+
if (node._components) {
|
|
78
|
+
node._components.forEach(comp => {
|
|
79
|
+
indexMap.set(comp, result.length);
|
|
80
|
+
result.push(componentToJSON(comp, indexMap));
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
result[indexMap.get(node)] = {
|
|
84
|
+
__type__: 'cc.Node',
|
|
85
|
+
_name: node._name,
|
|
86
|
+
_objFlags: node._objFlags,
|
|
87
|
+
_parent: node._parent ? { __id__: indexMap.get(node._parent) } : null,
|
|
88
|
+
_children: node._children?.map(c => ({ __id__: indexMap.get(c) })) || [],
|
|
89
|
+
_active: node._active,
|
|
90
|
+
_components: node._components?.map(c => ({ __id__: indexMap.get(c) })) || [],
|
|
91
|
+
_prefab: null,
|
|
92
|
+
_opacity: node._opacity,
|
|
93
|
+
_color: node._color.toJSON(),
|
|
94
|
+
_contentSize: node._contentSize.toJSON(),
|
|
95
|
+
_anchorPoint: node._anchorPoint.toJSON(),
|
|
96
|
+
_trs: node._trs.toJSON(),
|
|
97
|
+
_eulerAngles: node._eulerAngles.toJSON(),
|
|
98
|
+
_skewX: node._skewX,
|
|
99
|
+
_skewY: node._skewY,
|
|
100
|
+
_is3DNode: node._is3DNode,
|
|
101
|
+
_groupIndex: node._groupIndex,
|
|
102
|
+
groupIndex: node.groupIndex,
|
|
103
|
+
_id: node._id || ''
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
if (this._scene?._children) {
|
|
107
|
+
this._scene._children.forEach(child => processNode(child));
|
|
108
|
+
}
|
|
109
|
+
if (this._scene) {
|
|
110
|
+
result[1] = {
|
|
111
|
+
__type__: 'cc.Scene',
|
|
112
|
+
_objFlags: this._scene._objFlags,
|
|
113
|
+
_parent: null,
|
|
114
|
+
_children: this._scene._children?.map(c => ({ __id__: indexMap.get(c) })) || [],
|
|
115
|
+
_active: this._scene._active,
|
|
116
|
+
_components: [],
|
|
117
|
+
_prefab: null,
|
|
118
|
+
_opacity: this._scene._opacity,
|
|
119
|
+
_color: this._scene._color.toJSON(),
|
|
120
|
+
_contentSize: this._scene._contentSize.toJSON(),
|
|
121
|
+
_anchorPoint: this._scene._anchorPoint.toJSON(),
|
|
122
|
+
_trs: this._scene._trs.toJSON(),
|
|
123
|
+
_is3DNode: this._scene._is3DNode,
|
|
124
|
+
_groupIndex: this._scene._groupIndex,
|
|
125
|
+
groupIndex: this._scene.groupIndex,
|
|
126
|
+
autoReleaseAssets: this._scene.autoReleaseAssets || false,
|
|
127
|
+
_id: this._scene._id || ''
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function componentToJSON(comp, indexMap) {
|
|
134
|
+
const json = {
|
|
135
|
+
__type__: comp.__type__,
|
|
136
|
+
_name: comp._name || '',
|
|
137
|
+
_objFlags: comp._objFlags || 0,
|
|
138
|
+
node: { __id__: indexMap.get(comp.node) },
|
|
139
|
+
_enabled: comp._enabled !== false
|
|
140
|
+
};
|
|
141
|
+
for (const key of Object.keys(comp)) {
|
|
142
|
+
if (['__type__', '_name', '_objFlags', 'node', '_enabled', '_id'].includes(key))
|
|
143
|
+
continue;
|
|
144
|
+
const val = comp[key];
|
|
145
|
+
if (val === undefined)
|
|
146
|
+
continue;
|
|
147
|
+
json[key] = val && typeof val.toJSON === 'function' ? val.toJSON() : val;
|
|
148
|
+
}
|
|
149
|
+
json._id = comp._id || '';
|
|
150
|
+
return json;
|
|
151
|
+
}
|
|
152
|
+
function createObject(item) {
|
|
153
|
+
const type = item.__type__;
|
|
154
|
+
if (type === 'cc.SceneAsset')
|
|
155
|
+
return null;
|
|
156
|
+
if (type === 'cc.Scene') {
|
|
157
|
+
const scene = new CCScene();
|
|
158
|
+
scene._id = item._id || '';
|
|
159
|
+
if (item._active !== undefined)
|
|
160
|
+
scene._active = item._active;
|
|
161
|
+
if (item.autoReleaseAssets !== undefined)
|
|
162
|
+
scene.autoReleaseAssets = item.autoReleaseAssets;
|
|
163
|
+
return scene;
|
|
164
|
+
}
|
|
165
|
+
if (type === 'cc.Node') {
|
|
166
|
+
const node = new CCNode(item._name || 'Node');
|
|
167
|
+
node._id = item._id || '';
|
|
168
|
+
copyNodeProps(node, item);
|
|
169
|
+
return node;
|
|
170
|
+
}
|
|
171
|
+
const comp = createComponentInstance(type);
|
|
172
|
+
if (comp) {
|
|
173
|
+
copyComponentProps(comp, item);
|
|
174
|
+
return comp;
|
|
175
|
+
}
|
|
176
|
+
const obj = { __type__: type };
|
|
177
|
+
for (const key of Object.keys(item)) {
|
|
178
|
+
obj[key] = item[key];
|
|
179
|
+
}
|
|
180
|
+
return obj;
|
|
181
|
+
}
|
|
182
|
+
function createComponentInstance(type) {
|
|
183
|
+
switch (type) {
|
|
184
|
+
case 'cc.Canvas': return new CCCanvas();
|
|
185
|
+
case 'cc.Widget': return new CCWidget();
|
|
186
|
+
case 'cc.Sprite': return new CCSprite();
|
|
187
|
+
case 'cc.Label': return new CCLabel();
|
|
188
|
+
case 'cc.Button': return new CCButton();
|
|
189
|
+
case 'cc.Camera': return new CCCamera();
|
|
190
|
+
default: return null;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function copyComponentProps(comp, item) {
|
|
194
|
+
for (const key of Object.keys(item)) {
|
|
195
|
+
if (['__type__', '_name', '_objFlags', 'node', '_enabled', '_id'].includes(key))
|
|
196
|
+
continue;
|
|
197
|
+
comp[key] = item[key];
|
|
198
|
+
}
|
|
199
|
+
if (item._id)
|
|
200
|
+
comp._id = item._id;
|
|
201
|
+
}
|
|
202
|
+
function copyNodeProps(node, item) {
|
|
203
|
+
if (item._active !== undefined)
|
|
204
|
+
node._active = item._active;
|
|
205
|
+
if (item._opacity !== undefined)
|
|
206
|
+
node._opacity = item._opacity;
|
|
207
|
+
if (item._is3DNode !== undefined)
|
|
208
|
+
node._is3DNode = item._is3DNode;
|
|
209
|
+
if (item._groupIndex !== undefined)
|
|
210
|
+
node._groupIndex = item._groupIndex;
|
|
211
|
+
if (item.groupIndex !== undefined)
|
|
212
|
+
node.groupIndex = item.groupIndex;
|
|
213
|
+
if (item._skewX !== undefined)
|
|
214
|
+
node._skewX = item._skewX;
|
|
215
|
+
if (item._skewY !== undefined)
|
|
216
|
+
node._skewY = item._skewY;
|
|
217
|
+
if (item._color)
|
|
218
|
+
node._color.set(item._color.r, item._color.g, item._color.b, item._color.a);
|
|
219
|
+
if (item._contentSize)
|
|
220
|
+
node._contentSize.set(item._contentSize.width, item._contentSize.height);
|
|
221
|
+
if (item._anchorPoint)
|
|
222
|
+
node._anchorPoint.set(item._anchorPoint.x, item._anchorPoint.y);
|
|
223
|
+
if (item._trs?.array)
|
|
224
|
+
item._trs.array.forEach((v, i) => node._trs.array[i] = v);
|
|
225
|
+
if (item._eulerAngles)
|
|
226
|
+
node._eulerAngles.set(item._eulerAngles.x, item._eulerAngles.y, item._eulerAngles.z);
|
|
227
|
+
}
|
|
228
|
+
function setupReferences(obj, item, objects) {
|
|
229
|
+
if (!obj)
|
|
230
|
+
return;
|
|
231
|
+
if (obj.__type__ === 'cc.Scene' || obj.__type__ === 'cc.Node') {
|
|
232
|
+
if (item._parent)
|
|
233
|
+
obj._parent = objects[item._parent.__id__];
|
|
234
|
+
if (item._children)
|
|
235
|
+
obj._children = item._children.map((c) => objects[c.__id__]).filter(Boolean);
|
|
236
|
+
if (item._components) {
|
|
237
|
+
obj._components = item._components.map((c) => objects[c.__id__]).filter(Boolean);
|
|
238
|
+
obj._components.forEach((c) => { if (c)
|
|
239
|
+
c.node = obj; });
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
constructor(width = 0, height = 0) {
|
|
6
|
-
this.__type__ = 'cc.Size';
|
|
7
|
-
this.width = width;
|
|
8
|
-
this.height = height;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
this.
|
|
13
|
-
this
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
module.exports = CCSize;
|
|
1
|
+
export default class CCSize {
|
|
2
|
+
__type__;
|
|
3
|
+
width;
|
|
4
|
+
height;
|
|
5
|
+
constructor(width = 0, height = 0) {
|
|
6
|
+
this.__type__ = 'cc.Size';
|
|
7
|
+
this.width = width;
|
|
8
|
+
this.height = height;
|
|
9
|
+
}
|
|
10
|
+
set(width, height) {
|
|
11
|
+
this.width = width;
|
|
12
|
+
this.height = height;
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
toJSON() {
|
|
16
|
+
return {
|
|
17
|
+
__type__: this.__type__,
|
|
18
|
+
width: this.width,
|
|
19
|
+
height: this.height
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -1,94 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
23
|
-
this.
|
|
24
|
-
this.
|
|
25
|
-
this.
|
|
26
|
-
|
|
27
|
-
this.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
+
import CCComponent from './CCComponent.js';
|
|
2
|
+
import CCVec2 from './CCVec2.js';
|
|
3
|
+
const default_sprite_splash = 'a23235d1-15db-4b95-8439-a2e005bfff91';
|
|
4
|
+
export default class CCSprite extends CCComponent {
|
|
5
|
+
_materials;
|
|
6
|
+
_srcBlendFactor;
|
|
7
|
+
_dstBlendFactor;
|
|
8
|
+
_spriteFrame;
|
|
9
|
+
_type;
|
|
10
|
+
_sizeMode;
|
|
11
|
+
_fillType;
|
|
12
|
+
_fillCenter;
|
|
13
|
+
_fillStart;
|
|
14
|
+
_fillRange;
|
|
15
|
+
_isTrimmedMode;
|
|
16
|
+
_atlas;
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
this.__type__ = 'cc.Sprite';
|
|
20
|
+
this._materials = [{ __uuid__: 'eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432' }];
|
|
21
|
+
this._srcBlendFactor = 770;
|
|
22
|
+
this._dstBlendFactor = 771;
|
|
23
|
+
this._spriteFrame = null;
|
|
24
|
+
this._type = 0;
|
|
25
|
+
this._sizeMode = 0;
|
|
26
|
+
this._fillType = 0;
|
|
27
|
+
this._fillCenter = new CCVec2();
|
|
28
|
+
this._fillStart = 0;
|
|
29
|
+
this._fillRange = 0;
|
|
30
|
+
this._isTrimmedMode = true;
|
|
31
|
+
this._atlas = null;
|
|
32
|
+
this.setSpriteFrame(default_sprite_splash);
|
|
33
|
+
}
|
|
34
|
+
setSpriteFrame(uuid) {
|
|
35
|
+
this._spriteFrame = { __uuid__: uuid };
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
setSizeMode(mode) {
|
|
39
|
+
this._sizeMode = mode;
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
getProp() {
|
|
43
|
+
const SIZE_MODE = ['CUSTOM', 'RAW', 'TRIMMED'];
|
|
44
|
+
const SPRITE_TYPE = ['SIMPLE', 'SLICED', 'TILED', 'FILLED', 'MESH'];
|
|
45
|
+
return {
|
|
46
|
+
sizeMode: SIZE_MODE[this._sizeMode] || this._sizeMode,
|
|
47
|
+
type: SPRITE_TYPE[this._type] || this._type,
|
|
48
|
+
trim: this._isTrimmedMode
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
setProp(props) {
|
|
52
|
+
if (props.sizeMode !== undefined)
|
|
53
|
+
this.setSizeMode(props.sizeMode);
|
|
54
|
+
if (props.spriteFrame !== undefined)
|
|
55
|
+
this.setSpriteFrame(props.spriteFrame);
|
|
56
|
+
if (props.type !== undefined)
|
|
57
|
+
this._type = props.type;
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
toJSON() {
|
|
61
|
+
return {
|
|
62
|
+
__type__: this.__type__,
|
|
63
|
+
_name: this._name,
|
|
64
|
+
_objFlags: this._objFlags,
|
|
65
|
+
node: this.node,
|
|
66
|
+
_enabled: this._enabled,
|
|
67
|
+
_materials: this._materials,
|
|
68
|
+
_srcBlendFactor: this._srcBlendFactor,
|
|
69
|
+
_dstBlendFactor: this._dstBlendFactor,
|
|
70
|
+
_spriteFrame: this._spriteFrame,
|
|
71
|
+
_type: this._type,
|
|
72
|
+
_sizeMode: this._sizeMode,
|
|
73
|
+
_fillType: this._fillType,
|
|
74
|
+
_fillCenter: this._fillCenter.toJSON(),
|
|
75
|
+
_fillStart: this._fillStart,
|
|
76
|
+
_fillRange: this._fillRange,
|
|
77
|
+
_isTrimmedMode: this._isTrimmedMode,
|
|
78
|
+
_atlas: this._atlas,
|
|
79
|
+
_id: this._id
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -1,74 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
this.
|
|
8
|
-
this.
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
get
|
|
17
|
-
set
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
get
|
|
27
|
-
set
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
+
export default class CCTrs {
|
|
2
|
+
__type__;
|
|
3
|
+
ctor;
|
|
4
|
+
array;
|
|
5
|
+
constructor() {
|
|
6
|
+
this.__type__ = 'TypedArray';
|
|
7
|
+
this.ctor = 'Float64Array';
|
|
8
|
+
this.array = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1];
|
|
9
|
+
}
|
|
10
|
+
get x() { return this.array[0]; }
|
|
11
|
+
set x(v) { this.array[0] = v; }
|
|
12
|
+
get y() { return this.array[1]; }
|
|
13
|
+
set y(v) { this.array[1] = v; }
|
|
14
|
+
get z() { return this.array[2]; }
|
|
15
|
+
set z(v) { this.array[2] = v; }
|
|
16
|
+
get scaleX() { return this.array[7]; }
|
|
17
|
+
set scaleX(v) { this.array[7] = v; }
|
|
18
|
+
get scaleY() { return this.array[8]; }
|
|
19
|
+
set scaleY(v) { this.array[8] = v; }
|
|
20
|
+
get scaleZ() { return this.array[9]; }
|
|
21
|
+
set scaleZ(v) { this.array[9] = v; }
|
|
22
|
+
get rotX() { return this.array[3]; }
|
|
23
|
+
set rotX(v) { this.array[3] = v; }
|
|
24
|
+
get rotY() { return this.array[4]; }
|
|
25
|
+
set rotY(v) { this.array[4] = v; }
|
|
26
|
+
get rotZ() { return this.array[5]; }
|
|
27
|
+
set rotZ(v) { this.array[5] = v; }
|
|
28
|
+
get rotW() { return this.array[6]; }
|
|
29
|
+
set rotW(v) { this.array[6] = v; }
|
|
30
|
+
setPosition(x, y, z = 0) {
|
|
31
|
+
this.array[0] = x;
|
|
32
|
+
this.array[1] = y;
|
|
33
|
+
this.array[2] = z;
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
setScale(x, y = x, z = 1) {
|
|
37
|
+
this.array[7] = x;
|
|
38
|
+
this.array[8] = y;
|
|
39
|
+
this.array[9] = z;
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
toJSON() {
|
|
43
|
+
return {
|
|
44
|
+
__type__: this.__type__,
|
|
45
|
+
ctor: this.ctor,
|
|
46
|
+
array: [...this.array]
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|