運行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