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 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,35 +60,51 @@ 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
+
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
- 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
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('运行 cocos-cli --help 查看可用命令');
124
+ console.error('运行 cocos2d-cli --help 查看可用命令');
109
125
  process.exit(1);
110
126
  }
111
127
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cocos2d-cli",
3
- "version": "1.1.1",
3
+ "version": "1.2.1",
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": {