我的python版本是2.7,texturepacker版本是3.2.1,使用的操作系统是windows7。如果是在MAC或者Linux下方法也是一样的。texturepacker支持mac系统,但不知道是否支持linux。
啥也不说了,直接上python的脚本。
# -*- coding: cp936 -*-
import os,sys
imagedir = 'D:\\SVN\\前端\\公共\\武将图片\\hero1230'#图片所在文件夹
outplistdir = 'D:\\SVN\\前端\\公共\\武将图片\\AllHeroPlist'#打包后输出的文件夹
comend = 'texturepacker'#图片打包软件,这里要把这个软件加入到环境变量中,要不然就要写这个软件的完整路径print "imagedir = %s \noutdir = "%imagedir,outplistdir
herolist = os.listdir(imagedir)
print "heave %d hero convert"%len(herolist)
for n in range(len(herolist)):
herodirtmp = imagedir + os.sep + herolist[n]
herotmplist = os.listdir(herodirtmp)
cmdtmp = comend
print "hero %s heave image = %d"%(str(herolist[n]),len(herotmplist))
allImage = ""
for im in range(len(herotmplist)):
allImage = allImage + " " + herodirtmp + os.sep + herotmplist[im]
cmdtmp = cmdtmp + " " + allImage +\
" --data " + outplistdir + os.sep + herolist[n] + ".plist"\
" --sheet " + outplistdir + os.sep + herolist[n] + ".pvr.ccz"\
" --opt RGBA4444 --dither-fs-alpha --content-protection \19e5c826f732e5325e58d0c52488c7ac"
os.system(cmdtmp)
我是把texturepacker所在位置加入到了环境变量中,如果你没有加你就要在运行命行的时候cd到这个目录,或者写上程序的全路径,要查看texturepacker的帮助,只要在命令提示行下输入texturepacker就可以看到了。