cocos2d-cli 1.0.3

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.
@@ -0,0 +1,404 @@
1
+ /**
2
+ * Cocos Creator 2.4.x 组件模板
3
+ * 从编辑器导出的默认组件属性
4
+ */
5
+
6
+ function generateId() {
7
+ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
8
+ let result = '';
9
+ for (let i = 0; i < 22; i++) {
10
+ result += chars.charAt(Math.floor(Math.random() * chars.length));
11
+ }
12
+ return result;
13
+ }
14
+
15
+ const DEFAULT_MATERIAL = { "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" };
16
+ const DEFAULT_SPRITE_FRAME = { "__uuid__": "8cdb44ac-a3f6-449f-b354-7cd48cf84061" };
17
+ const SPLASH_SPRITE_FRAME = { "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" };
18
+ const BUTTON_NORMAL_SPRITE = { "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" };
19
+ const BUTTON_PRESSED_SPRITE = { "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" };
20
+ const BUTTON_DISABLED_SPRITE = { "__uuid__": "29158224-f8dd-4661-a796-1ffab537140e" };
21
+ const PARTICLE_FILE = { "__uuid__": "b2687ac4-099e-403c-a192-ff477686f4f5" };
22
+ const PARTICLE_SPRITE = { "__uuid__": "472df5d3-35e7-4184-9e6c-7f41bee65ee3" };
23
+
24
+ const Components = {
25
+ sprite: (nodeId) => ({
26
+ "__type__": "cc.Sprite",
27
+ "_name": "",
28
+ "_objFlags": 0,
29
+ "node": { "__id__": nodeId },
30
+ "_enabled": true,
31
+ "_materials": [DEFAULT_MATERIAL],
32
+ "_srcBlendFactor": 770,
33
+ "_dstBlendFactor": 771,
34
+ "_spriteFrame": DEFAULT_SPRITE_FRAME,
35
+ "_type": 0,
36
+ "_sizeMode": 1,
37
+ "_fillType": 0,
38
+ "_fillCenter": { "__type__": "cc.Vec2", "x": 0, "y": 0 },
39
+ "_fillStart": 0,
40
+ "_fillRange": 0,
41
+ "_isTrimmedMode": true,
42
+ "_atlas": null,
43
+ "_id": generateId()
44
+ }),
45
+
46
+ label: (nodeId) => ({
47
+ "__type__": "cc.Label",
48
+ "_name": "",
49
+ "_objFlags": 0,
50
+ "node": { "__id__": nodeId },
51
+ "_enabled": true,
52
+ "_materials": [DEFAULT_MATERIAL],
53
+ "_srcBlendFactor": 770,
54
+ "_dstBlendFactor": 771,
55
+ "_string": "Label",
56
+ "_N$string": "Label",
57
+ "_fontSize": 40,
58
+ "_lineHeight": 40,
59
+ "_enableWrapText": true,
60
+ "_N$file": null,
61
+ "_isSystemFontUsed": true,
62
+ "_spacingX": 0,
63
+ "_batchAsBitmap": false,
64
+ "_styleFlags": 0,
65
+ "_underlineHeight": 0,
66
+ "_N$horizontalAlign": 1,
67
+ "_N$verticalAlign": 1,
68
+ "_N$fontFamily": "Arial",
69
+ "_N$overflow": 0,
70
+ "_N$cacheMode": 0,
71
+ "_id": generateId()
72
+ }),
73
+
74
+ button: (nodeId) => ({
75
+ "__type__": "cc.Button",
76
+ "_name": "",
77
+ "_objFlags": 0,
78
+ "node": { "__id__": nodeId },
79
+ "_enabled": true,
80
+ "_normalMaterial": null,
81
+ "_grayMaterial": null,
82
+ "duration": 0.1,
83
+ "zoomScale": 1.2,
84
+ "clickEvents": [],
85
+ "_N$interactable": true,
86
+ "_N$enableAutoGrayEffect": false,
87
+ "_N$transition": 3,
88
+ "transition": 3,
89
+ "_N$normalColor": {
90
+ "__type__": "cc.Color",
91
+ "r": 255,
92
+ "g": 255,
93
+ "b": 255,
94
+ "a": 255
95
+ },
96
+ "_N$pressedColor": {
97
+ "__type__": "cc.Color",
98
+ "r": 200,
99
+ "g": 200,
100
+ "b": 200,
101
+ "a": 255
102
+ },
103
+ "pressedColor": {
104
+ "__type__": "cc.Color",
105
+ "r": 200,
106
+ "g": 200,
107
+ "b": 200,
108
+ "a": 255
109
+ },
110
+ "_N$hoverColor": {
111
+ "__type__": "cc.Color",
112
+ "r": 255,
113
+ "g": 255,
114
+ "b": 255,
115
+ "a": 255
116
+ },
117
+ "hoverColor": {
118
+ "__type__": "cc.Color",
119
+ "r": 255,
120
+ "g": 255,
121
+ "b": 255,
122
+ "a": 255
123
+ },
124
+ "_N$disabledColor": {
125
+ "__type__": "cc.Color",
126
+ "r": 120,
127
+ "g": 120,
128
+ "b": 120,
129
+ "a": 200
130
+ },
131
+ "_N$normalSprite": BUTTON_NORMAL_SPRITE,
132
+ "_N$pressedSprite": BUTTON_PRESSED_SPRITE,
133
+ "pressedSprite": BUTTON_PRESSED_SPRITE,
134
+ "_N$hoverSprite": BUTTON_NORMAL_SPRITE,
135
+ "hoverSprite": BUTTON_NORMAL_SPRITE,
136
+ "_N$disabledSprite": BUTTON_DISABLED_SPRITE,
137
+ "_N$target": null,
138
+ "_id": generateId()
139
+ }),
140
+
141
+ layout: (nodeId) => ({
142
+ "__type__": "cc.Layout",
143
+ "_name": "",
144
+ "_objFlags": 0,
145
+ "node": { "__id__": nodeId },
146
+ "_enabled": true,
147
+ "_layoutSize": {
148
+ "__type__": "cc.Size",
149
+ "width": 200,
150
+ "height": 150
151
+ },
152
+ "_resize": 1,
153
+ "_N$layoutType": 2,
154
+ "_N$cellSize": {
155
+ "__type__": "cc.Size",
156
+ "width": 40,
157
+ "height": 40
158
+ },
159
+ "_N$startAxis": 0,
160
+ "_N$paddingLeft": 0,
161
+ "_N$paddingRight": 0,
162
+ "_N$paddingTop": 0,
163
+ "_N$paddingBottom": 0,
164
+ "_N$spacingX": 0,
165
+ "_N$spacingY": 0,
166
+ "_N$verticalDirection": 1,
167
+ "_N$horizontalDirection": 0,
168
+ "_N$affectedByScale": false,
169
+ "_id": generateId()
170
+ }),
171
+
172
+ widget: (nodeId) => ({
173
+ "__type__": "cc.Widget",
174
+ "_name": "",
175
+ "_objFlags": 0,
176
+ "node": { "__id__": nodeId },
177
+ "_enabled": true,
178
+ "alignMode": 1,
179
+ "_target": null,
180
+ "_alignFlags": 0,
181
+ "_left": 0,
182
+ "_right": 0,
183
+ "_top": 0,
184
+ "_bottom": 0,
185
+ "_verticalCenter": 0,
186
+ "_horizontalCenter": 0,
187
+ "_isAbsLeft": true,
188
+ "_isAbsRight": true,
189
+ "_isAbsTop": true,
190
+ "_isAbsBottom": true,
191
+ "_isAbsHorizontalCenter": true,
192
+ "_isAbsVerticalCenter": true,
193
+ "_originalWidth": 0,
194
+ "_originalHeight": 0,
195
+ "_id": generateId()
196
+ }),
197
+
198
+ particleSystem: (nodeId) => ({
199
+ "__type__": "cc.ParticleSystem",
200
+ "_name": "",
201
+ "_objFlags": 0,
202
+ "node": { "__id__": nodeId },
203
+ "_enabled": true,
204
+ "_materials": [DEFAULT_MATERIAL],
205
+ "_srcBlendFactor": 770,
206
+ "_dstBlendFactor": 1,
207
+ "_custom": false,
208
+ "_file": PARTICLE_FILE,
209
+ "_spriteFrame": PARTICLE_SPRITE,
210
+ "_texture": null,
211
+ "_stopped": true,
212
+ "playOnLoad": true,
213
+ "autoRemoveOnFinish": false,
214
+ "totalParticles": 200,
215
+ "duration": -1,
216
+ "emissionRate": 999.999985098839,
217
+ "life": 0.20000000298023224,
218
+ "lifeVar": 0.5,
219
+ "_startColor": {
220
+ "__type__": "cc.Color",
221
+ "r": 202,
222
+ "g": 200,
223
+ "b": 86,
224
+ "a": 163
225
+ },
226
+ "_startColorVar": {
227
+ "__type__": "cc.Color",
228
+ "r": 229,
229
+ "g": 255,
230
+ "b": 173,
231
+ "a": 198
232
+ },
233
+ "_endColor": {
234
+ "__type__": "cc.Color",
235
+ "r": 173,
236
+ "g": 161,
237
+ "b": 19,
238
+ "a": 214
239
+ },
240
+ "_endColorVar": {
241
+ "__type__": "cc.Color",
242
+ "r": 107,
243
+ "g": 249,
244
+ "b": 249,
245
+ "a": 188
246
+ },
247
+ "angle": 360,
248
+ "angleVar": 360,
249
+ "startSize": 3.369999885559082,
250
+ "startSizeVar": 50,
251
+ "endSize": 30.31999969482422,
252
+ "endSizeVar": 0,
253
+ "startSpin": -47.369998931884766,
254
+ "startSpinVar": 0,
255
+ "endSpin": -47.369998931884766,
256
+ "endSpinVar": -142.11000061035156,
257
+ "sourcePos": {
258
+ "__type__": "cc.Vec2",
259
+ "x": 0,
260
+ "y": 0
261
+ },
262
+ "posVar": {
263
+ "__type__": "cc.Vec2",
264
+ "x": 7,
265
+ "y": 7
266
+ },
267
+ "_positionType": 1,
268
+ "positionType": 1,
269
+ "emitterMode": 0,
270
+ "gravity": {
271
+ "__type__": "cc.Vec2",
272
+ "x": 0.25,
273
+ "y": 0.8600000143051147
274
+ },
275
+ "speed": 0,
276
+ "speedVar": 190.7899932861328,
277
+ "tangentialAccel": -92.11000061035156,
278
+ "tangentialAccelVar": 65.79000091552734,
279
+ "radialAccel": -671.0499877929688,
280
+ "radialAccelVar": 65.79000091552734,
281
+ "rotationIsDir": false,
282
+ "startRadius": 0,
283
+ "startRadiusVar": 0,
284
+ "endRadius": 0,
285
+ "endRadiusVar": 0,
286
+ "rotatePerS": 0,
287
+ "rotatePerSVar": 0,
288
+ "_N$preview": true,
289
+ "_id": generateId()
290
+ }),
291
+
292
+ camera: (nodeId) => ({
293
+ "__type__": "cc.Camera",
294
+ "_name": "",
295
+ "_objFlags": 0,
296
+ "node": { "__id__": nodeId },
297
+ "_enabled": true,
298
+ "_cullingMask": 4294967295,
299
+ "_clearFlags": 7,
300
+ "_backgroundColor": {
301
+ "__type__": "cc.Color",
302
+ "r": 0,
303
+ "g": 0,
304
+ "b": 0,
305
+ "a": 255
306
+ },
307
+ "_depth": -1,
308
+ "_zoomRatio": 1,
309
+ "_targetTexture": null,
310
+ "_fov": 60,
311
+ "_orthoSize": 10,
312
+ "_nearClip": 1,
313
+ "_farClip": 4096,
314
+ "_ortho": true,
315
+ "_rect": {
316
+ "__type__": "cc.Rect",
317
+ "x": 0,
318
+ "y": 0,
319
+ "width": 1,
320
+ "height": 1
321
+ },
322
+ "_renderStages": 1,
323
+ "_alignWithScreen": true,
324
+ "_id": generateId()
325
+ }),
326
+
327
+ canvas: (nodeId) => ({
328
+ "__type__": "cc.Canvas",
329
+ "_name": "",
330
+ "_objFlags": 0,
331
+ "node": { "__id__": nodeId },
332
+ "_enabled": true,
333
+ "_designResolution": {
334
+ "__type__": "cc.Size",
335
+ "width": 960,
336
+ "height": 640
337
+ },
338
+ "_fitWidth": false,
339
+ "_fitHeight": true,
340
+ "_id": generateId()
341
+ })
342
+ };
343
+
344
+ /**
345
+ * 创建默认节点数据
346
+ */
347
+ function createNodeData(name, parentId, options = {}) {
348
+ return {
349
+ "__type__": "cc.Node",
350
+ "_name": name,
351
+ "_objFlags": 0,
352
+ "_parent": { "__id__": parentId },
353
+ "_children": [],
354
+ "_active": options.active !== false,
355
+ "_components": [],
356
+ "_prefab": null,
357
+ "_opacity": 255,
358
+ "_color": {
359
+ "__type__": "cc.Color",
360
+ "r": 255,
361
+ "g": 255,
362
+ "b": 255,
363
+ "a": 255
364
+ },
365
+ "_contentSize": {
366
+ "__type__": "cc.Size",
367
+ "width": options.width || 0,
368
+ "height": options.height || 0
369
+ },
370
+ "_anchorPoint": {
371
+ "__type__": "cc.Vec2",
372
+ "x": 0.5,
373
+ "y": 0.5
374
+ },
375
+ "_trs": {
376
+ "__type__": "TypedArray",
377
+ "ctor": "Float64Array",
378
+ "array": [
379
+ options.x || 0,
380
+ options.y || 0,
381
+ 0, 0, 0, 0, 1,
382
+ 1, 1, 1
383
+ ]
384
+ },
385
+ "_eulerAngles": {
386
+ "__type__": "cc.Vec3",
387
+ "x": 0,
388
+ "y": 0,
389
+ "z": 0
390
+ },
391
+ "_skewX": 0,
392
+ "_skewY": 0,
393
+ "_is3DNode": false,
394
+ "_groupIndex": 0,
395
+ "groupIndex": 0,
396
+ "_id": generateId()
397
+ };
398
+ }
399
+
400
+ module.exports = {
401
+ Components,
402
+ generateId,
403
+ createNodeData
404
+ };