cocos2d-cli 1.1.0 → 1.1.2
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/bin/cocos-cli.js +38 -26
- package/package.json +1 -1
- package/src/commands/create-scene.js +381 -351
- package/src/commands/prefab-create.js +437 -25
- package/src/commands/set.js +19 -0
- package/src/commands/tree.js +2 -2
- package/src/lib/fire-utils.js +3 -3
package/bin/cocos-cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
3
|
* Cocos Creator CLI
|
|
4
4
|
* Command-line tools for AI to read and manipulate Cocos Creator 2.4.x project scenes
|
|
5
5
|
*/
|
|
@@ -16,7 +16,7 @@ const commands = {
|
|
|
16
16
|
'remove': '../src/commands/remove',
|
|
17
17
|
delete: '../src/commands/delete',
|
|
18
18
|
build: '../src/commands/build',
|
|
19
|
-
'prefab
|
|
19
|
+
'create-prefab': '../src/commands/prefab-create',
|
|
20
20
|
'create-scene': '../src/commands/create-scene'
|
|
21
21
|
};
|
|
22
22
|
|
|
@@ -26,7 +26,7 @@ function showHelp() {
|
|
|
26
26
|
Cocos Creator CLI - 场景/预制体操作工具集
|
|
27
27
|
|
|
28
28
|
用法:
|
|
29
|
-
|
|
29
|
+
cocos2d-cli <command> [options]
|
|
30
30
|
|
|
31
31
|
命令:
|
|
32
32
|
tree <场景.fire | 预制体.prefab> 查看节点树(获取索引)
|
|
@@ -37,8 +37,8 @@ Cocos Creator CLI - 场景/预制体操作工具集
|
|
|
37
37
|
remove <文件> <索引> 删除节点或组件
|
|
38
38
|
delete <文件> <节点索引> 删除节点
|
|
39
39
|
build <项目目录> 构建组件映射
|
|
40
|
-
prefab
|
|
41
|
-
create-scene
|
|
40
|
+
create-prefab <输出.prefab> 从 stdin(JSON) 创建预制体
|
|
41
|
+
create-scene <输出.fire> 从 stdin(JSON) 创建场景
|
|
42
42
|
|
|
43
43
|
选项:
|
|
44
44
|
--name=<名称> 修改节点名称
|
|
@@ -54,31 +54,43 @@ Cocos Creator CLI - 场景/预制体操作工具集
|
|
|
54
54
|
--rotation=<角度> 修改旋转角度
|
|
55
55
|
--scaleX=<数值> 修改 X 缩放
|
|
56
56
|
--scaleY=<数值> 修改 Y 缩放
|
|
57
|
+
--string=<文字> 修改 Label 文字内容
|
|
58
|
+
--fontSize=<数值> 修改 Label 字体大小
|
|
59
|
+
--lineHeight=<数值> 修改 Label 行高
|
|
57
60
|
--type=sprite/label/button 添加节点时指定组件类型
|
|
58
61
|
--at=<索引> 添加节点时插入到子节点的指定位置(0=第一个)
|
|
59
62
|
|
|
60
|
-
create-scene
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
JSON 格式 (create-prefab / create-scene):
|
|
64
|
+
{
|
|
65
|
+
"name": "节点名称",
|
|
66
|
+
"width": 400,
|
|
67
|
+
"height": 300,
|
|
68
|
+
"x": 0,
|
|
69
|
+
"y": 0,
|
|
70
|
+
"color": "#336699",
|
|
71
|
+
"opacity": 255,
|
|
72
|
+
"components": [
|
|
73
|
+
"sprite",
|
|
74
|
+
{ "type": "widget", "top": 0, "left": 0, "right": 0, "bottom": 0 },
|
|
75
|
+
{ "type": "label", "string": "Hello", "fontSize": 32 }
|
|
76
|
+
],
|
|
77
|
+
"children": [...]
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
节点属性: name, width, height, x, y, color, opacity, anchorX, anchorY, rotation, scaleX, scaleY, active
|
|
81
|
+
组件类型: sprite, label, button, widget, layout, canvas, camera, particle
|
|
68
82
|
|
|
69
83
|
示例:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
│ └─ GoldLabel (label)
|
|
81
|
-
└─ GameArea" | cocos2.4 create-scene assets/game.fire
|
|
84
|
+
cocos2d-cli tree assets/main.fire
|
|
85
|
+
cocos2d-cli get assets/main.fire 5
|
|
86
|
+
cocos2d-cli set assets/main.fire 8 --x=100 --y=200 --color=#ff0000
|
|
87
|
+
cocos2d-cli add assets/main.fire 5 NewSprite --type=sprite --x=100
|
|
88
|
+
|
|
89
|
+
# 从 JSON 创建场景
|
|
90
|
+
type scene.json | cocos2d-cli create-scene assets/scene.fire
|
|
91
|
+
|
|
92
|
+
# 从 JSON 创建预制体
|
|
93
|
+
type panel.json | cocos2d-cli create-prefab assets/panel.prefab
|
|
82
94
|
|
|
83
95
|
版本: 1.1.0
|
|
84
96
|
`);
|
|
@@ -97,7 +109,7 @@ const commandPath = commands[commandName];
|
|
|
97
109
|
|
|
98
110
|
if (!commandPath) {
|
|
99
111
|
console.error(`未知命令: ${commandName}`);
|
|
100
|
-
console.error('运行
|
|
112
|
+
console.error('运行 cocos2d-cli --help 查看可用命令');
|
|
101
113
|
process.exit(1);
|
|
102
114
|
}
|
|
103
115
|
|