cocos2d-cli 1.1.1 → 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 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-create': '../src/commands/prefab-create',
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
- cocos2.4 <command> [options]
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-create <预制体路径> <根节点名称> 创建新预制体文件
41
- create-scene <输出路径.fire> [场景名称] 从 stdin 创建场景文件
40
+ create-prefab <输出.prefab> 从 stdin(JSON) 创建预制体
41
+ create-scene <输出.fire> 从 stdin(JSON) 创建场景
42
42
 
43
43
  选项:
44
44
  --name=<名称> 修改节点名称
@@ -60,33 +60,37 @@ Cocos Creator CLI - 场景/预制体操作工具集
60
60
  --type=sprite/label/button 添加节点时指定组件类型
61
61
  --at=<索引> 添加节点时插入到子节点的指定位置(0=第一个)
62
62
 
63
- create-scene 组件规则:
64
- 渲染组件(每节点仅一个): sprite, label, particle
65
- 功能组件(可多个共存): button, widget, layout, camera, canvas
66
-
67
- [错误] BtnConfirm (sprite, label) -- 多个渲染组件
68
- [正确] BtnConfirm (button, widget)
69
- └─ BtnText (label)
70
-
71
- create-scene 节点选项:
72
- #width=100 设置宽度
73
- #height=50 设置高度
74
- #x=10 设置 X 坐标
75
- #y=20 设置 Y 坐标
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
76
82
 
77
83
  示例:
78
- cocos2.4 tree assets/main.fire
79
- cocos2.4 get assets/main.fire 5
80
- cocos2.4 set assets/main.fire 8 --x=100 --y=200 --color=#ff0000
81
- cocos2.4 add assets/main.fire 5 NewSprite --type=sprite --x=100
82
- cocos2.4 prefab-create assets/MyPanel.prefab Panel
83
-
84
- # 从树形结构创建场景
85
- echo "Canvas (canvas)
86
- ├─ TopBar (sprite, widget) #width=720 #height=80
87
- │ ├─ ScoreLabel (label)
88
- │ └─ GoldLabel (label)
89
- └─ 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
90
94
 
91
95
  版本: 1.1.0
92
96
  `);
@@ -105,7 +109,7 @@ const commandPath = commands[commandName];
105
109
 
106
110
  if (!commandPath) {
107
111
  console.error(`未知命令: ${commandName}`);
108
- console.error('运行 cocos-cli --help 查看可用命令');
112
+ console.error('运行 cocos2d-cli --help 查看可用命令');
109
113
  process.exit(1);
110
114
  }
111
115
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cocos2d-cli",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Command-line tools for AI to read and manipulate Cocos Creator 2.4.x project scenes",
5
5
  "main": "bin/cocos-cli.js",
6
6
  "bin": {