【步兵 cocos2dx】texturePacker命令行 By EOS.
緊接上文,來講講texturePacker命令行的使用。雖然有經驗的大部份都會用,
那就幫忙新手早些上路(車)吧~ 滴~滴~滴~
那些參數
–premultiply-alpha 去除白邊(命令行必帶)
–dither-fs-alpha 抖動去條紋(這個最好別用,會出奇怪的問題)
–algorithm MaxRects 不必是正方形
–enable-rotation 允許旋轉
–format cocos2d 指定平臺
–pack-mode Best 質量最好
–trim 裁剪,去透明
–max-size 2048 設置最大矩形
–size-constraints NPOT 二的倍數
–maxrects-heuristics best 最優排列
–border-padding 0 邊界間距 0
–shape-padding 2 圖片間距 2
–opt RGBA4444 像素格式(高度壓縮,圖片體積小)
–opt RGBA8888 像素格式(有漸變出橫條的時候用這種模式)
–texture-format pvr2ccz 紋理格式(pvr.ccz)
這些參數基本上就夠用了~其他的可直接輸入texturePacker.exe然後回車
實際使用
local TPK = [["C:\Program Files (x86)\CodeAndWeb\TexturePacker\bin\TexturePacker.exe"]]
local TPKOPT = " --premultiply-alpha --algorithm MaxRects --enable-rotation --format cocos2d --pack-mode Best --trim --max-size 2048 --size-constraints NPOT --maxrects-heuristics best --border-padding 0 --shape-padding 2 --texture-format pvr2ccz "
function pack(prefix, hasGradient)
local tmpTPKOPT = nil
if not hasGradient then
tmpTPKOPT = TPKOPT.."--opt RGBA4444 "
else
tmpTPKOPT = TPKOPT.."--opt RGBA8888 "
end
if not tools.hasDir("ext") then
tools.cmd("mkdir ext")
end
local cmdStr = TPK..tmpTPKOPT..string.format("--data ./ext/%s.plist --sheet ./ext/%s.pvr.ccz %s >nul >nul", prefix, prefix, "./")
tools.cmd(cmdStr)--打包
end
這是愛的奉獻~這是…
還好控制住了,差點一言不合就唱歌。。。呼~
(gili gili eye~….gili gili mind~)
local lfs = require "lfs"
tools.cmd = os.execute
--獲取指定目錄的文件,第二參數是遞歸標識
function tools.getFileList(path, isInDir)
local ret = {}
for file in lfs.dir(path) do
if file ~= "." and file ~= ".." then
local f = path..'/'..file
local f_type = lfs.attributes(f).mode
if f_type == "directory" then
if isInDir then
tools.getFileList(f)
end
else
--print("\t "..f)
table.insert(ret, f)
end
end
end
return ret
end
--獲取指定目錄的文件夾,第二參數是遞歸標識
function tools.getDirList(path, isInDir)
local ret = {}
for file in lfs.dir(path) do
if file ~= "." and file ~= ".." then
local f = path..'/'..file
local f_type = lfs.attributes(f).mode
if f_type == "directory" then
--print("\t "..f)
table.insert(ret, f)
if isInDir then
tools.getDirList(f)
end
end
end
end
return ret
end
有了這些,我想其他的大家處理起來應該不會太難的=、=記得裝winlua
該結束了
長度剛剛好,好吧,我還是分享一下winLua吧= 3= (PS:就知道你們懶)
鏈接:http://pan.baidu.com/s/1bJHXBS 密碼:hs3s
See Again~
之前
真愛無價,歡迎打賞~