cocos2d-cli 1.1.1 → 1.2.1
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 +48 -32
- package/package.json +1 -1
- package/src/commands/create-scene.js +381 -403
- package/src/commands/prefab-create.js +449 -25
package/bin/cocos-cli.js
CHANGED
|
@@ -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=<名称> 修改节点名称
|
|
@@ -60,35 +60,51 @@ Cocos Creator CLI - 场景/预制体操作工具集
|
|
|
60
60
|
--type=sprite/label/button 添加节点时指定组件类型
|
|
61
61
|
--at=<索引> 添加节点时插入到子节点的指定位置(0=第一个)
|
|
62
62
|
|
|
63
|
-
create-scene
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
+
|
|
82
|
+
组件类型:
|
|
83
|
+
sprite - 精灵���默认白色方块,节点设置什么颜色就显示什么颜色
|
|
84
|
+
label - 文本,支持 string, fontSize, color(兼容)
|
|
85
|
+
button - 按钮,通常配合 sprite 使用才能看见
|
|
86
|
+
widget - 对齐,支持 top, bottom, left, right
|
|
87
|
+
layout - 布局,自动排列子节点
|
|
88
|
+
canvas - 画布,根节点使用
|
|
89
|
+
camera - 相机
|
|
90
|
+
particle - 粒子效果
|
|
91
|
+
|
|
92
|
+
注意:
|
|
93
|
+
- color 写在节点或 label 组件均可
|
|
94
|
+
- button 需要配合 sprite 才能看见按钮外观
|
|
95
|
+
- 必须通过 JSON 文件输入: type panel.json | cocos2d-cli create-prefab xxx.prefab
|
|
76
96
|
|
|
77
97
|
示例:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
│ └─ GoldLabel (label)
|
|
89
|
-
└─ GameArea" | cocos2.4 create-scene assets/game.fire
|
|
90
|
-
|
|
91
|
-
版本: 1.1.0
|
|
98
|
+
cocos2d-cli tree assets/main.fire
|
|
99
|
+
cocos2d-cli get assets/main.fire 5
|
|
100
|
+
cocos2d-cli set assets/main.fire 8 --x=100 --y=200 --color=#ff0000
|
|
101
|
+
cocos2d-cli add assets/main.fire 5 NewSprite --type=sprite --x=100
|
|
102
|
+
|
|
103
|
+
# 从 JSON 创建场景
|
|
104
|
+
type scene.json | cocos2d-cli create-scene assets/scene.fire
|
|
105
|
+
|
|
106
|
+
# 从 JSON 创建预制体
|
|
107
|
+
type panel.json | cocos2d-cli create-prefab assets/panel.prefab
|
|
92
108
|
`);
|
|
93
109
|
}
|
|
94
110
|
|
|
@@ -105,7 +121,7 @@ const commandPath = commands[commandName];
|
|
|
105
121
|
|
|
106
122
|
if (!commandPath) {
|
|
107
123
|
console.error(`未知命令: ${commandName}`);
|
|
108
|
-
console.error('运行
|
|
124
|
+
console.error('运行 cocos2d-cli --help 查看可用命令');
|
|
109
125
|
process.exit(1);
|
|
110
126
|
}
|
|
111
127
|
|