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.
Files changed (62) hide show
  1. package/data/script_map.json +25 -25
  2. package/dist/bin/cocos2d-cli.js +64 -0
  3. package/dist/src/commands/add-component.js +3 -0
  4. package/dist/src/commands/add.js +3 -0
  5. package/dist/src/commands/build.js +6 -0
  6. package/dist/src/commands/create-scene.js +3 -0
  7. package/dist/src/commands/get.js +3 -0
  8. package/dist/src/commands/prefab-create.js +109 -0
  9. package/dist/src/commands/remove-component.js +3 -0
  10. package/dist/src/commands/remove.js +3 -0
  11. package/dist/src/commands/screenshot.js +41 -0
  12. package/dist/src/commands/set-component.js +3 -0
  13. package/dist/src/commands/set.js +3 -0
  14. package/dist/src/commands/tree.js +24 -0
  15. package/{src → dist/src}/lib/cc/CCButton.js +115 -122
  16. package/{src → dist/src}/lib/cc/CCCamera.js +83 -93
  17. package/{src → dist/src}/lib/cc/CCCanvas.js +49 -54
  18. package/{src → dist/src}/lib/cc/CCColor.js +30 -32
  19. package/{src → dist/src}/lib/cc/CCComponent.js +39 -60
  20. package/{src → dist/src}/lib/cc/CCLabel.js +139 -146
  21. package/{src → dist/src}/lib/cc/CCNode.js +190 -256
  22. package/{src → dist/src}/lib/cc/CCObject.js +19 -23
  23. package/{src → dist/src}/lib/cc/CCPrefab.js +219 -242
  24. package/{src → dist/src}/lib/cc/CCRect.js +30 -32
  25. package/{src → dist/src}/lib/cc/CCRichText.js +38 -44
  26. package/{src → dist/src}/lib/cc/CCScene.js +32 -42
  27. package/dist/src/lib/cc/CCSceneAsset.js +242 -0
  28. package/{src → dist/src}/lib/cc/CCSize.js +22 -26
  29. package/{src → dist/src}/lib/cc/CCSprite.js +82 -94
  30. package/{src → dist/src}/lib/cc/CCTrs.js +49 -74
  31. package/{src → dist/src}/lib/cc/CCVec2.js +22 -26
  32. package/{src → dist/src}/lib/cc/CCVec3.js +26 -29
  33. package/{src → dist/src}/lib/cc/CCWidget.js +94 -98
  34. package/dist/src/lib/fire-utils.js +86 -0
  35. package/dist/src/lib/json-parser.js +114 -0
  36. package/dist/src/lib/node-utils.js +131 -0
  37. package/{src → dist/src}/lib/screenshot-core.js +242 -285
  38. package/dist/src/lib/templates.js +17 -0
  39. package/dist/src/lib/utils.js +81 -0
  40. package/package.json +40 -33
  41. package/bin/cocos2d-cli.js +0 -152
  42. package/src/commands/add-component.js +0 -112
  43. package/src/commands/add.js +0 -177
  44. package/src/commands/build.js +0 -78
  45. package/src/commands/create-scene.js +0 -181
  46. package/src/commands/get.js +0 -108
  47. package/src/commands/prefab-create.js +0 -111
  48. package/src/commands/remove-component.js +0 -111
  49. package/src/commands/remove.js +0 -99
  50. package/src/commands/screenshot.js +0 -108
  51. package/src/commands/set-component.js +0 -119
  52. package/src/commands/set.js +0 -107
  53. package/src/commands/tree.js +0 -29
  54. package/src/lib/cc/CCSceneAsset.js +0 -303
  55. package/src/lib/cc/index.js +0 -42
  56. package/src/lib/fire-utils.js +0 -374
  57. package/src/lib/json-parser.js +0 -185
  58. package/src/lib/node-utils.js +0 -395
  59. package/src/lib/screenshot/favicon.ico +0 -0
  60. package/src/lib/screenshot/index.html +0 -30
  61. package/src/lib/templates.js +0 -49
  62. package/src/lib/utils.js +0 -202
@@ -1,93 +1,83 @@
1
- const CCComponent = require('./CCComponent');
2
- const CCColor = require('./CCColor');
3
- const CCRect = require('./CCRect');
4
-
5
- /**
6
- * Cocos Creator Camera 组件
7
- */
8
- class CCCamera extends CCComponent {
9
- constructor() {
10
- super();
11
- this.__type__ = 'cc.Camera';
12
-
13
- this._cullingMask = 4294967295;
14
- this._clearFlags = 7;
15
- this._backgroundColor = new CCColor(0, 0, 0, 255);
16
- this._depth = -1;
17
- this._zoomRatio = 1;
18
- this._targetTexture = null;
19
- this._fov = 60;
20
- this._orthoSize = 10;
21
- this._nearClip = 1;
22
- this._farClip = 4096;
23
- this._ortho = true;
24
- this._rect = new CCRect(0, 0, 1, 1);
25
- this._renderStages = 1;
26
- this._alignWithScreen = true;
27
- }
28
-
29
- /**
30
- * 设置正交大小
31
- */
32
- setOrthoSize(size) {
33
- this._orthoSize = size;
34
- return this;
35
- }
36
-
37
- /**
38
- * 设置深度
39
- */
40
- setDepth(depth) {
41
- this._depth = depth;
42
- return this;
43
- }
44
-
45
- /**
46
- * 设置背景颜色
47
- */
48
- setBackgroundColor(r, g, b, a = 255) {
49
- this._backgroundColor.set(r, g, b, a);
50
- return this;
51
- }
52
-
53
- /**
54
- * 转换为属性面板显示格式
55
- */
56
- toPanelJSON() {
57
- return {
58
- ...super.toPanelJSON(),
59
- depth: this._depth,
60
- zoomRatio: this._zoomRatio,
61
- ortho: this._ortho,
62
- orthoSize: this._orthoSize,
63
- backgroundColor: this._backgroundColor ? `#${this._backgroundColor.r.toString(16).padStart(2,'0')}${this._backgroundColor.g.toString(16).padStart(2,'0')}${this._backgroundColor.b.toString(16).padStart(2,'0')}` : '#000000'
64
- };
65
- }
66
-
67
- toJSON() {
68
- return {
69
- __type__: this.__type__,
70
- _name: this._name,
71
- _objFlags: this._objFlags,
72
- node: this.node,
73
- _enabled: this._enabled,
74
- _cullingMask: this._cullingMask,
75
- _clearFlags: this._clearFlags,
76
- _backgroundColor: this._backgroundColor.toJSON(),
77
- _depth: this._depth,
78
- _zoomRatio: this._zoomRatio,
79
- _targetTexture: this._targetTexture,
80
- _fov: this._fov,
81
- _orthoSize: this._orthoSize,
82
- _nearClip: this._nearClip,
83
- _farClip: this._farClip,
84
- _ortho: this._ortho,
85
- _rect: this._rect.toJSON(),
86
- _renderStages: this._renderStages,
87
- _alignWithScreen: this._alignWithScreen,
88
- _id: this._id
89
- };
90
- }
91
- }
92
-
93
- module.exports = CCCamera;
1
+ import CCComponent from './CCComponent.js';
2
+ import CCColor from './CCColor.js';
3
+ import CCRect from './CCRect.js';
4
+ export default class CCCamera extends CCComponent {
5
+ _cullingMask;
6
+ _clearFlags;
7
+ _backgroundColor;
8
+ _depth;
9
+ _zoomRatio;
10
+ _targetTexture;
11
+ _fov;
12
+ _orthoSize;
13
+ _nearClip;
14
+ _farClip;
15
+ _ortho;
16
+ _rect;
17
+ _renderStages;
18
+ _alignWithScreen;
19
+ constructor() {
20
+ super();
21
+ this.__type__ = 'cc.Camera';
22
+ this._cullingMask = 4294967295;
23
+ this._clearFlags = 7;
24
+ this._backgroundColor = new CCColor(0, 0, 0, 255);
25
+ this._depth = -1;
26
+ this._zoomRatio = 1;
27
+ this._targetTexture = null;
28
+ this._fov = 60;
29
+ this._orthoSize = 10;
30
+ this._nearClip = 1;
31
+ this._farClip = 4096;
32
+ this._ortho = true;
33
+ this._rect = new CCRect(0, 0, 1, 1);
34
+ this._renderStages = 1;
35
+ this._alignWithScreen = true;
36
+ }
37
+ setOrthoSize(size) {
38
+ this._orthoSize = size;
39
+ return this;
40
+ }
41
+ setDepth(depth) {
42
+ this._depth = depth;
43
+ return this;
44
+ }
45
+ setBackgroundColor(r, g, b, a = 255) {
46
+ this._backgroundColor.set(r, g, b, a);
47
+ return this;
48
+ }
49
+ toPanelJSON() {
50
+ return {
51
+ ...super.getProp(),
52
+ depth: this._depth,
53
+ zoomRatio: this._zoomRatio,
54
+ ortho: this._ortho,
55
+ orthoSize: this._orthoSize,
56
+ backgroundColor: this._backgroundColor ? `#${this._backgroundColor.r.toString(16).padStart(2, '0')}${this._backgroundColor.g.toString(16).padStart(2, '0')}${this._backgroundColor.b.toString(16).padStart(2, '0')}` : '#000000'
57
+ };
58
+ }
59
+ toJSON() {
60
+ return {
61
+ __type__: this.__type__,
62
+ _name: this._name,
63
+ _objFlags: this._objFlags,
64
+ node: this.node,
65
+ _enabled: this._enabled,
66
+ _cullingMask: this._cullingMask,
67
+ _clearFlags: this._clearFlags,
68
+ _backgroundColor: this._backgroundColor.toJSON(),
69
+ _depth: this._depth,
70
+ _zoomRatio: this._zoomRatio,
71
+ _targetTexture: this._targetTexture,
72
+ _fov: this._fov,
73
+ _orthoSize: this._orthoSize,
74
+ _nearClip: this._nearClip,
75
+ _farClip: this._farClip,
76
+ _ortho: this._ortho,
77
+ _rect: this._rect.toJSON(),
78
+ _renderStages: this._renderStages,
79
+ _alignWithScreen: this._alignWithScreen,
80
+ _id: this._id
81
+ };
82
+ }
83
+ }
@@ -1,54 +1,49 @@
1
- const CCComponent = require('./CCComponent');
2
- const CCSize = require('./CCSize');
3
-
4
- /**
5
- * Cocos Creator Canvas 组件
6
- */
7
- class CCCanvas extends CCComponent {
8
- constructor() {
9
- super();
10
- this.__type__ = 'cc.Canvas';
11
-
12
- this._designResolution = new CCSize(960, 640);
13
- this._fitWidth = false;
14
- this._fitHeight = true;
15
- }
16
-
17
- setProp(props) {
18
- super.setProp(props);
19
- if (props.designResolution) {
20
- this._designResolution = new CCSize(props.designResolution.width, props.designResolution.height);
21
- }
22
- if (props.fitWidth !== undefined) this._fitWidth = props.fitWidth;
23
- if (props.fitHeight !== undefined) this._fitHeight = props.fitHeight;
24
- return this;
25
- }
26
-
27
- getProp() {
28
- return {
29
- ...super.getProp(),
30
- designResolution: {
31
- width: this._designResolution?.width ?? 960,
32
- height: this._designResolution?.height ?? 640
33
- },
34
- fitWidth: this._fitWidth,
35
- fitHeight: this._fitHeight
36
- };
37
- }
38
-
39
- toJSON() {
40
- return {
41
- __type__: this.__type__,
42
- _name: this._name,
43
- _objFlags: this._objFlags,
44
- node: this.node,
45
- _enabled: this._enabled,
46
- _designResolution: this._designResolution.toJSON(),
47
- _fitWidth: this._fitWidth,
48
- _fitHeight: this._fitHeight,
49
- _id: this._id
50
- };
51
- }
52
- }
53
-
54
- module.exports = CCCanvas;
1
+ import CCComponent from './CCComponent.js';
2
+ import CCSize from './CCSize.js';
3
+ export default class CCCanvas extends CCComponent {
4
+ _designResolution;
5
+ _fitWidth;
6
+ _fitHeight;
7
+ constructor() {
8
+ super();
9
+ this.__type__ = 'cc.Canvas';
10
+ this._designResolution = new CCSize(960, 640);
11
+ this._fitWidth = false;
12
+ this._fitHeight = true;
13
+ }
14
+ setProp(props) {
15
+ super.setProp(props);
16
+ if (props.designResolution) {
17
+ this._designResolution = new CCSize(props.designResolution.width, props.designResolution.height);
18
+ }
19
+ if (props.fitWidth !== undefined)
20
+ this._fitWidth = props.fitWidth;
21
+ if (props.fitHeight !== undefined)
22
+ this._fitHeight = props.fitHeight;
23
+ return this;
24
+ }
25
+ getProp() {
26
+ return {
27
+ ...super.getProp(),
28
+ designResolution: {
29
+ width: this._designResolution?.width ?? 960,
30
+ height: this._designResolution?.height ?? 640
31
+ },
32
+ fitWidth: this._fitWidth,
33
+ fitHeight: this._fitHeight
34
+ };
35
+ }
36
+ toJSON() {
37
+ return {
38
+ __type__: this.__type__,
39
+ _name: this._name,
40
+ _objFlags: this._objFlags,
41
+ node: this.node,
42
+ _enabled: this._enabled,
43
+ _designResolution: this._designResolution.toJSON(),
44
+ _fitWidth: this._fitWidth,
45
+ _fitHeight: this._fitHeight,
46
+ _id: this._id
47
+ };
48
+ }
49
+ }
@@ -1,32 +1,30 @@
1
- /**
2
- * Cocos Creator 颜色类
3
- */
4
- class CCColor {
5
- constructor(r = 255, g = 255, b = 255, a = 255) {
6
- this.__type__ = 'cc.Color';
7
- this.r = r;
8
- this.g = g;
9
- this.b = b;
10
- this.a = a;
11
- }
12
-
13
- set(r, g, b, a = 255) {
14
- this.r = r;
15
- this.g = g;
16
- this.b = b;
17
- this.a = a;
18
- return this;
19
- }
20
-
21
- toJSON() {
22
- return {
23
- __type__: this.__type__,
24
- r: this.r,
25
- g: this.g,
26
- b: this.b,
27
- a: this.a
28
- };
29
- }
30
- }
31
-
32
- module.exports = CCColor;
1
+ export default class CCColor {
2
+ __type__;
3
+ r;
4
+ g;
5
+ b;
6
+ a;
7
+ constructor(r = 255, g = 255, b = 255, a = 255) {
8
+ this.__type__ = 'cc.Color';
9
+ this.r = r;
10
+ this.g = g;
11
+ this.b = b;
12
+ this.a = a;
13
+ }
14
+ set(r, g, b, a = 255) {
15
+ this.r = r;
16
+ this.g = g;
17
+ this.b = b;
18
+ this.a = a;
19
+ return this;
20
+ }
21
+ toJSON() {
22
+ return {
23
+ __type__: this.__type__,
24
+ r: this.r,
25
+ g: this.g,
26
+ b: this.b,
27
+ a: this.a
28
+ };
29
+ }
30
+ }
@@ -1,60 +1,39 @@
1
- const CCObject = require('./CCObject');
2
- const { generateId } = require('../utils');
3
-
4
- /**
5
- * Cocos Creator 组件基类
6
- */
7
- class CCComponent extends CCObject {
8
- constructor() {
9
- super('');
10
- this.__type__ = 'cc.Component';
11
-
12
- // 关联的节点
13
- this.node = null;
14
-
15
- // 启用状态
16
- this._enabled = true;
17
-
18
- // 唯一标识(22位压缩格式)
19
- this._id = generateId();
20
- }
21
-
22
- /**
23
- * 设置节点引用
24
- */
25
- setNode(nodeIndex) {
26
- this.node = { __id__: nodeIndex };
27
- return this;
28
- }
29
-
30
- /**
31
- * 获取属性(子类重写)
32
- */
33
- getProp() {
34
- return {
35
- class: this.__type__,
36
- enabled: this._enabled
37
- };
38
- }
39
-
40
- /**
41
- * 设置属性(子类重写)
42
- */
43
- setProp(props) {
44
- if (props.enabled !== undefined) this._enabled = props.enabled;
45
- return this;
46
- }
47
-
48
- toJSON() {
49
- return {
50
- __type__: this.__type__,
51
- _name: this._name,
52
- _objFlags: this._objFlags,
53
- node: this.node,
54
- _enabled: this._enabled,
55
- _id: this._id
56
- };
57
- }
58
- }
59
-
60
- module.exports = CCComponent;
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;
7
+ constructor() {
8
+ super('');
9
+ this.__type__ = 'cc.Component';
10
+ this.node = null;
11
+ this._enabled = true;
12
+ this._id = generateId();
13
+ }
14
+ setNode(nodeIndex) {
15
+ this.node = { __id__: nodeIndex };
16
+ return this;
17
+ }
18
+ getProp() {
19
+ return {
20
+ class: this.__type__,
21
+ enabled: this._enabled
22
+ };
23
+ }
24
+ setProp(props) {
25
+ if (props.enabled !== undefined)
26
+ this._enabled = props.enabled;
27
+ return this;
28
+ }
29
+ toJSON() {
30
+ return {
31
+ __type__: this.__type__,
32
+ _name: this._name,
33
+ _objFlags: this._objFlags,
34
+ node: this.node,
35
+ _enabled: this._enabled,
36
+ _id: this._id
37
+ };
38
+ }
39
+ }