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 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-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=<名称> 修改节点名称
@@ -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
- sprite, label, button, layout, widget, camera, canvas, particle
62
-
63
- create-scene 节点选项:
64
- #width=100 设置宽度
65
- #height=50 设置高度
66
- #x=10 设置 X 坐标
67
- #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
68
82
 
69
83
  示例:
70
- cocos2.4 tree assets/main.fire
71
- cocos2.4 get assets/main.fire 5
72
- cocos2.4 set assets/main.fire 8 --x=100 --y=200 --color=#ff0000
73
- cocos2.4 add assets/main.fire 5 NewSprite --type=sprite --x=100
74
- cocos2.4 prefab-create assets/MyPanel.prefab Panel
75
-
76
- # 从树形结构创建场景
77
- echo "Canvas (canvas)
78
- ├─ TopBar (sprite, widget) #width=720 #height=80
79
- │ ├─ ScoreLabel (label)
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('运行 cocos-cli --help 查看可用命令');
112
+ console.error('运行 cocos2d-cli --help 查看可用命令');
101
113
  process.exit(1);
102
114
  }
103
115
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cocos2d-cli",
3
- "version": "1.1.0",
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": {