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,146 +1,139 @@
1
- const CCComponent = require('./CCComponent');
2
-
3
- /**
4
- * Cocos Creator Label 组件
5
- */
6
- class CCLabel extends CCComponent {
7
- constructor() {
8
- super();
9
- this.__type__ = 'cc.Label';
10
-
11
- this._materials = [{ __uuid__: 'eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432' }];
12
- this._srcBlendFactor = 770;
13
- this._dstBlendFactor = 771;
14
- this._string = '';
15
- this._N$string = '';
16
- this._fontSize = 40;
17
- this._lineHeight = 40;
18
- this._enableWrapText = true;
19
- this._N$file = null;
20
- this._isSystemFontUsed = true;
21
- this._spacingX = 0;
22
- this._batchAsBitmap = false;
23
- this._styleFlags = 0;
24
- this._underlineHeight = 0;
25
- this._N$horizontalAlign = 1;
26
- this._N$verticalAlign = 1;
27
- this._N$fontFamily = 'Arial';
28
- this._N$overflow = 0;
29
- this._N$cacheMode = 0;
30
- }
31
-
32
- /**
33
- * 设置文本内容
34
- */
35
- setString(str) {
36
- this._string = str;
37
- this._N$string = str;
38
- return this;
39
- }
40
-
41
- /**
42
- * 设置字体大小
43
- */
44
- setFontSize(size) {
45
- this._fontSize = size;
46
- this._lineHeight = size;
47
- return this;
48
- }
49
-
50
- /**
51
- * 设置字体
52
- */
53
- setFontFamily(family) {
54
- this._N$fontFamily = family;
55
- return this;
56
- }
57
-
58
- /**
59
- * 获取属性
60
- */
61
- getProp() {
62
- const H_ALIGN = ['LEFT', 'CENTER', 'RIGHT'];
63
- const V_ALIGN = ['TOP', 'CENTER', 'BOTTOM'];
64
- const OVERFLOW = ['NONE', 'CLAMP', 'SHRINK', 'RESIZE_HEIGHT'];
65
- return {
66
- string: this._string,
67
- fontSize: this._fontSize,
68
- lineHeight: this._lineHeight,
69
- fontFamily: this._N$fontFamily,
70
- horizontalAlign: H_ALIGN[this._N$horizontalAlign] || this._N$horizontalAlign,
71
- verticalAlign: V_ALIGN[this._N$verticalAlign] || this._N$verticalAlign,
72
- overflow: OVERFLOW[this._N$overflow] || this._N$overflow,
73
- wrap: this._enableWrapText
74
- };
75
- }
76
-
77
- /**
78
- * 将语义化对齐字符串转为数字
79
- * horizontalAlign: left=0, center=1, right=2
80
- * verticalAlign: top=0, center=1, bottom=2
81
- */
82
- static parseHAlign(value) {
83
- if (typeof value === 'number') return value;
84
- switch (String(value).toLowerCase()) {
85
- case 'left': return 0;
86
- case 'center': return 1;
87
- case 'right': return 2;
88
- default: return 1;
89
- }
90
- }
91
-
92
- static parseVAlign(value) {
93
- if (typeof value === 'number') return value;
94
- switch (String(value).toLowerCase()) {
95
- case 'top': return 0;
96
- case 'center': return 1;
97
- case 'bottom': return 2;
98
- default: return 1;
99
- }
100
- }
101
-
102
- /**
103
- * 设置属性
104
- */
105
- setProp(props) {
106
- if (props.string !== undefined) this.setString(props.string);
107
- if (props.fontSize !== undefined) this.setFontSize(props.fontSize);
108
- if (props.lineHeight !== undefined) this._lineHeight = props.lineHeight;
109
- if (props.fontFamily !== undefined) this.setFontFamily(props.fontFamily);
110
- if (props.horizontalAlign !== undefined) this._N$horizontalAlign = CCLabel.parseHAlign(props.horizontalAlign);
111
- if (props.verticalAlign !== undefined) this._N$verticalAlign = CCLabel.parseVAlign(props.verticalAlign);
112
- return this;
113
- }
114
-
115
- toJSON() {
116
- return {
117
- __type__: this.__type__,
118
- _name: this._name,
119
- _objFlags: this._objFlags,
120
- node: this.node,
121
- _enabled: this._enabled,
122
- _materials: this._materials,
123
- _srcBlendFactor: this._srcBlendFactor,
124
- _dstBlendFactor: this._dstBlendFactor,
125
- _string: this._string,
126
- _N$string: this._N$string,
127
- _fontSize: this._fontSize,
128
- _lineHeight: this._fontSize,
129
- _enableWrapText: this._enableWrapText,
130
- _N$file: this._N$file,
131
- _isSystemFontUsed: this._isSystemFontUsed,
132
- _spacingX: this._spacingX,
133
- _batchAsBitmap: this._batchAsBitmap,
134
- _styleFlags: this._styleFlags,
135
- _underlineHeight: this._underlineHeight,
136
- _N$horizontalAlign: this._N$horizontalAlign,
137
- _N$verticalAlign: this._N$verticalAlign,
138
- _N$fontFamily: this._N$fontFamily,
139
- _N$overflow: this._N$overflow,
140
- _N$cacheMode: this._N$cacheMode,
141
- _id: this._id
142
- };
143
- }
144
- }
145
-
146
- module.exports = CCLabel;
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;
22
+ constructor() {
23
+ super();
24
+ this.__type__ = 'cc.Label';
25
+ this._materials = [{ __uuid__: 'eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432' }];
26
+ this._srcBlendFactor = 770;
27
+ this._dstBlendFactor = 771;
28
+ this._string = '';
29
+ this._N$string = '';
30
+ this._fontSize = 40;
31
+ this._lineHeight = 40;
32
+ this._enableWrapText = true;
33
+ this._N$file = null;
34
+ this._isSystemFontUsed = true;
35
+ this._spacingX = 0;
36
+ this._batchAsBitmap = false;
37
+ this._styleFlags = 0;
38
+ this._underlineHeight = 0;
39
+ this._N$horizontalAlign = 1;
40
+ this._N$verticalAlign = 1;
41
+ this._N$fontFamily = 'Arial';
42
+ this._N$overflow = 0;
43
+ this._N$cacheMode = 0;
44
+ }
45
+ setString(str) {
46
+ this._string = str;
47
+ this._N$string = str;
48
+ return this;
49
+ }
50
+ setFontSize(size) {
51
+ this._fontSize = size;
52
+ this._lineHeight = size;
53
+ return this;
54
+ }
55
+ setFontFamily(family) {
56
+ this._N$fontFamily = family;
57
+ return this;
58
+ }
59
+ getProp() {
60
+ const H_ALIGN = ['LEFT', 'CENTER', 'RIGHT'];
61
+ const V_ALIGN = ['TOP', 'CENTER', 'BOTTOM'];
62
+ const OVERFLOW = ['NONE', 'CLAMP', 'SHRINK', 'RESIZE_HEIGHT'];
63
+ return {
64
+ string: this._string,
65
+ fontSize: this._fontSize,
66
+ lineHeight: this._lineHeight,
67
+ fontFamily: this._N$fontFamily,
68
+ horizontalAlign: H_ALIGN[this._N$horizontalAlign] || this._N$horizontalAlign,
69
+ verticalAlign: V_ALIGN[this._N$verticalAlign] || this._N$verticalAlign,
70
+ overflow: OVERFLOW[this._N$overflow] || this._N$overflow,
71
+ wrap: this._enableWrapText
72
+ };
73
+ }
74
+ static parseHAlign(value) {
75
+ if (typeof value === 'number')
76
+ return value;
77
+ switch (String(value).toLowerCase()) {
78
+ case 'left': return 0;
79
+ case 'center': return 1;
80
+ case 'right': return 2;
81
+ default: return 1;
82
+ }
83
+ }
84
+ static parseVAlign(value) {
85
+ if (typeof value === 'number')
86
+ return value;
87
+ switch (String(value).toLowerCase()) {
88
+ case 'top': return 0;
89
+ case 'center': return 1;
90
+ case 'bottom': return 2;
91
+ default: return 1;
92
+ }
93
+ }
94
+ setProp(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);
108
+ return this;
109
+ }
110
+ toJSON() {
111
+ return {
112
+ __type__: this.__type__,
113
+ _name: this._name,
114
+ _objFlags: this._objFlags,
115
+ node: this.node,
116
+ _enabled: this._enabled,
117
+ _materials: this._materials,
118
+ _srcBlendFactor: this._srcBlendFactor,
119
+ _dstBlendFactor: this._dstBlendFactor,
120
+ _string: this._string,
121
+ _N$string: this._N$string,
122
+ _fontSize: this._fontSize,
123
+ _lineHeight: this._fontSize,
124
+ _enableWrapText: this._enableWrapText,
125
+ _N$file: this._N$file,
126
+ _isSystemFontUsed: this._isSystemFontUsed,
127
+ _spacingX: this._spacingX,
128
+ _batchAsBitmap: this._batchAsBitmap,
129
+ _styleFlags: this._styleFlags,
130
+ _underlineHeight: this._underlineHeight,
131
+ _N$horizontalAlign: this._N$horizontalAlign,
132
+ _N$verticalAlign: this._N$verticalAlign,
133
+ _N$fontFamily: this._N$fontFamily,
134
+ _N$overflow: this._N$overflow,
135
+ _N$cacheMode: this._N$cacheMode,
136
+ _id: this._id
137
+ };
138
+ }
139
+ }