运行cmd, TexturePacker
android
–sheet <filename>
+生成的图片名,支持png,jpg,pvr,pvr.czz,pvr.gz格式
+示例:--sheet out.png
正则表达式
–data <filename>
安全
--data out.plist
–format <format>
bash
--format cocos2d
–auto-sdless
--auto-sd
sheet
和data
名必须含有-hd
或@2x
,TP会自动生成不带后缀的sd数据.–texturepath <path>
工具
sheet
文件的路径前加你--texturepath image/tower
这样在plist文件中realTextureFileName
的值为image/tower/out.png
out.png
的目录–trim-sprite-namespa
--trim-sprite-name
这样在plist文件中<key>001.png</key>
会变成<key>001</key>
–replace <regexp>=<string>
翻译
<string>
替换掉拼接图片的文件名中正则表达式匹配的字符串–ignore-files <regexp>
rest
*
或?
,但在使用bash时应避免使用通配符.先上一张cocos2d-x支持的最大图片尺寸:
还有官方的这句话:code
For the developers, if you want to cross platforms and run your games smoothly, you should keep your texture size less than 1024*1024, that is the lowest restriction for most machines.
–width/–height <int>
--width 100
--height 100
1 |
error: Could not fit all sprites into the sprite sheet. |
–max-width/–max-height/–max-size <int>
--max-width 1024
--max-height 1024
前面两个等价于后面 --max-size 1024
2048
1 |
error: Sprite sheet size is too small. |
–allow-free-size
--allow-free-size
–shape-padding <int>
2
--shape-padding 100
–border-padding <int>
2
--border-padding 100
–padding
--padding 100
--allow-free-size
可能和你想象的不太同样–inner-padding
--inner-padding 100
–enable-rotation/diable-rotation
--enable-rotation
--diable-rotation
–trim/no-trim
--trim
no-trim
--no-trim
更安全些,我会在后面的仔细讲一下.–crop
--crop
–trim-threshold
0~255
,默认为0
.--trim-threshold
–disable-auto-alias
--disable-auto-alias
–opt
--opt RGB444
##常见问题
错误: error: Error in sprite: .png: Failed to load image!
解决方案: 去掉目标路径末尾的.png试试.
错误: error: Could not fit all sprites into the sprite sheet.
解决方案:
1.查看有无设置--width or --height,这个错误一般是因为输出图片的尺寸过小致使的.
2.查看有无--max-width/--max-height/--max-size,没有的话加上,有的话将参数值改大一些.
错误: error: Sprite sheet size is too small.
解决方案:参见上个错误中的解决方案2,--max-width/--max-height/--max-size默认值为2048,试着改为4096试试,若是解决了,不要高兴,由于大多数移动设备都不支持这个尺寸,能够考虑分开打包.
错误: error: Unknown argument –XXX - please check parameters or visit http://www.texturepacker.com for newer version
解决方案: 检查XXX的拼写是否正确
问题: 程序中得到图片的尺寸与打包前不一致
解决方案: 检查参数是否含有--crop,有的话删除,有没有--no-trim,没有的话加上.
##后记 讲了那么多参数,其实经常使用的没有几个,下面这个是我最终使用的命令: TexturePacker --sheet out.png --data out.plist --allow-free-size --no-trim --max-size 1024 --format cocos2d animation