怎么样分割由texturepacker 注册机生成的SpriteSheets图和plist文件

shahdza 的BLOG
用户名:shahdza
文章数:114
评论数:75
访问量:281625
注册日期:
阅读量:5863
阅读量:12276
阅读量:332596
阅读量:1038484
51CTO推荐博文
【唠叨】&&&&在Cocos中,plist文件&是非常常见的配置文件。它是特定格式的xml文件。&&&&例如:小图打包成大图的纹理图片、制作粒子特效、帧动画等,都用到了plist文件作为配置文件。&&&&本节要介绍的是:如何创建plist文件,以及读取plist文件中的数据信息。& &&【扩展阅读】&&&&&(维基百科)&&&&&(COCOS2D-X中的PLIST文件格式详解)&&&&&(Spritesheet的plist文件格式解析)【plist文件】&&&&属性列表(Property List)文件是一种用来存储序列化后的对象的文件。&&&&属性列表文件的文件扩展名为 .plist,因此通常被称为plist文件。1、plist文件在Cocos中的应用&&&&(1)图片纹理的配置信息&&&&&&&&将多个纹理小图片打包成一个大图片,并生成plist文件。用于配置各个小图的名称、尺寸大小、以及在大图中的所在的矩形区域位置等信息。&&&&&&&&可以使用TexturePacker工具,将多个小碎图的纹理打包成一张大图片。&&&&(2)帧动画的配置信息&&&&&&&&将帧动画的数据信息,生成为plist配置文件。包含每帧间隔、动画重复次数、每一帧所需的图片、每张图片的名称、尺寸大小、以及在大图中所在的矩形区域位置等信息。&&&&(3)粒子特效的配置信息&&&&&&&&将粒子特效的数据信息,生成为plist配置文件。包含粒子发射器的位置信息、发射器模式、最大粒子数量、发射角度、发射速度、纹理贴图等等信息。&&&&(4)还有其它。2、plist文件格式&&&&plist文件为属性列表文件,类似于键值对(key-value)的形式。&&&&plist文件举例://
&?xml&version="1.0"&encoding="UTF-8"?&
&!DOCTYPE&plist&PUBLIC&"-//Apple//DTD&PLIST&1.0//EN"&"/DTDs/PropertyList-1.0.dtd"&
&plist&version="1.0"&
&key&dict&/key&
&key&name&/key&
&string&Alice&/string&
&key&age&/key&
&string&20&/string&
&key&array&/key&
&integer&0&/integer&
&integer&1&/integer&
&integer&2&/integer&
&key&bool&/key&
&key&data&/key&
&data&&/data&
&key&date&/key&
&date&T16:47:11Z&/date&
&key&number&/key&
&integer&123456&/integer&
&key&string&/key&
&string&hello&world!&/string&
//&&&&属性类型有:&&&&&&&&& Dictionary :字典。(子属性列表为:键值对形式)&&&&&&&&& Array& & & & &:数组。(子属性列表为:数组值的形式)&&&&&&&&& Boolean & &:逻辑值。(true / false)&&&&&&&&& Number & &:数字。&&&&&&&&& String& & & &:字符串。&&&&&&&&& Date & & & & &:日期。&&&&&&&&& Data & & & & &:数据。&&&&其中,根节点只能为字典或数组。&&&&并且在字典或数组中,键对应的值依然可以为以上的各个属性类型。3、创建/编辑plist文件&&&&在Mac OS系统中,XCode可以直接创建和编辑plist文件。&&&&当然也可以使用plist编辑软件,或直接使用文本编辑器进行编写。&&&&XCode中,编辑plist文件非常方便。&&&&其中,根节点Root,只能为Dictionary、或Array类型。650) this.width=650;" src="/wyfs02/M02/59/CB/wKiom1TiMoLiwX2QAAETD6stsBk455.jpg" title="1.png" alt="wKiom1TiMoLiwX2QAAETD6stsBk455.jpg" />&&&&以上plist文件数据,代码形式如下://
&?xml&version="1.0"&encoding="UTF-8"?&
&!DOCTYPE&plist&PUBLIC&"-//Apple//DTD&PLIST&1.0//EN"&"/DTDs/PropertyList-1.0.dtd"&
&plist&version="1.0"&
&key&dict&/key&
&key&name&/key&
&string&Alice&/string&
&key&age&/key&
&string&20&/string&
&key&array&/key&
&integer&0&/integer&
&integer&1&/integer&
&integer&2&/integer&
&key&bool&/key&
&key&data&/key&
&data&&/data&
&key&date&/key&
&date&T16:47:11Z&/date&
&key&number&/key&
&integer&123456&/integer&
&key&string&/key&
&string&hello&world!&/string&
//&&&&我想大家应该能读得懂把。4、读取plist文件&&&&接下来讲讲如何读取plist文件的数据信息。&&&&(1)根节点为Dictionary :使用&FileUtils::getInstance()-&getValueMapFromFile(); 读取为一个ValueMap 。&&&&(2)根节点为Array & & & & &:使用&FileUtils::getInstance()-&getValueVectorFromFile(); 读取为一个ValueVector 。&&&&使用举例://
//&文件路径
std::string&path&=&"/soft/cocos2d-x-3.4/projects/Demo34/Resources/testPlist.plist";
//&读取plist文件
//&以根节点为字典Dictionary为例
//&根节点为字典Dictionary&,&读取为一个ValueMap
ValueMap&plist&=&FileUtils::getInstance()-&getValueMapFromFile(path);
//&若根节点为数组Array&,&读取为一个ValueVector
//&ValueVector&plist&=&FileUtils::getInstance()-&getValueVectorFromFile(path);
//&获取数据
//&读取&"string"
CCLOG("string&=&%s",&(plist["string"].asString()).c_str());
//&读取&"dict"&,&也是一个字典ValueMap
ValueMap&&dict&=&plist["dict"].asValueMap();
CCLOG("name&=&%s",&(dict["name"].asString()).c_str());
CCLOG("age&&=&%s",&(dict["age"].asString()).c_str());
//&读取&"array"&,&是一个数组ValueVector
ValueVector&&array&=&plist["array"].asValueVector();
for&(int&i&=&0;&i&&&array.size();&i++)&{
Value&&value&=&array[i];
CCLOG("%d",&value.asInt());
//本文出自 “” 博客,请务必保留此出处
了这篇文章
类别:┆阅读(0)┆评论(0)原地址:http://blog.csdn.net/linuxchen/article/details/
Python 脚本:(来自网络)
unpack_plist.py
命令行: python unpack_plist.py &plist文件名称&
例子: python unpack_plist.py &common & & &## plist文件全名为 common.plist
import&os,sys&&
from&xml.etree&import&ElementTree&&
from&PIL&import&Image&&
def&tree_to_dict(tree):&&
&&&&d&=&{}&&
&&&&for&index,&item&in&enumerate(tree):&&
&&&&&&&&if&item.tag&==&'key':&&
&&&&&&&&&&&&if&tree[index+1].tag&==&'string':&&
&&&&&&&&&&&&&&&&d[item.text]&=&tree[index&+&1].text&&
&&&&&&&&&&&&elif&tree[index&+&1].tag&==&'true':&&
&&&&&&&&&&&&&&&&d[item.text]&=&True&&
&&&&&&&&&&&&elif&tree[index&+&1].tag&==&'false':&&
&&&&&&&&&&&&&&&&d[item.text]&=&False&&
&&&&&&&&&&&&elif&tree[index+1].tag&==&'dict':&&
&&&&&&&&&&&&&&&&d[item.text]&=&tree_to_dict(tree[index+1])&&
&&&&return&d&&
def&gen_png_from_plist(plist_filename,&png_filename):&&
&&&&file_path&=&plist_filename.replace('.plist',&'')&&
&&&&big_image&=&Image.open(png_filename)&&
&&&&root&=&ElementTree.fromstring(open(plist_filename,&'r').read())&&
&&&&plist_dict&=&tree_to_dict(root[0])&&
&&&&to_list&=&lambda&x:&x.replace('{','').replace('}','').split(',')&&
&&&&for&k,v&in&plist_dict['frames'].items():&&
&&&&&&&&rectlist&=&to_list(v['frame'])&&
&&&&&&&&width&=&int(&rectlist[3]&if&v['rotated']&else&rectlist[2]&)&&
&&&&&&&&height&=&int(&rectlist[2]&if&v['rotated']&else&rectlist[3]&)&&
&&&&&&&&box=(&&&
&&&&&&&&&&&&int(rectlist[0]),&&
&&&&&&&&&&&&int(rectlist[1]),&&
&&&&&&&&&&&&int(rectlist[0])&+&width,&&
&&&&&&&&&&&&int(rectlist[1])&+&height,&&
&&&&&&&&&&&&)&&
&&&&&&&&sizelist&=&[&int(x)&for&x&in&to_list(v['sourceSize'])]&&
&&&&&&&&rect_on_big&=&big_image.crop(box)&&
&&&&&&&&if&v['rotated']:&&
&&&&&&&&&&&&rect_on_big&=&rect_on_big.rotate(90)&&
&&&&&&&&result_image&=&Image.new('RGBA',&sizelist,&(0,0,0,0))&&
&&&&&&&&if&v['rotated']:&&
&&&&&&&&&&&&result_box=(&&
&&&&&&&&&&&&&&&&(&sizelist[0]&-&height&)/2,&&
&&&&&&&&&&&&&&&&(&sizelist[1]&-&width&)/2,&&
&&&&&&&&&&&&&&&&(&sizelist[0]&+&height&)/2,&&
&&&&&&&&&&&&&&&&(&sizelist[1]&+&width&)/2&&
&&&&&&&&&&&&&&&&)&&
&&&&&&&&else:&&
&&&&&&&&&&&&result_box=(&&
&&&&&&&&&&&&&&&&(&sizelist[0]&-&width&)/2,&&
&&&&&&&&&&&&&&&&(&sizelist[1]&-&height&)/2,&&
&&&&&&&&&&&&&&&&(&sizelist[0]&+&width&)/2,&&
&&&&&&&&&&&&&&&&(&sizelist[1]&+&height&)/2&&
&&&&&&&&&&&&&&&&)&&
&&&&&&&&result_image.paste(rect_on_big,&result_box,&mask=0)&&
&&&&&&&&if&not&os.path.isdir(file_path):&&
&&&&&&&&&&&&os.mkdir(file_path)&&
&&&&&&&&outfile&=&(file_path+'/'&+&k).replace('gift_',&'')&&
&&&&&&&&print&outfile,&"generated"&&
&&&&&&&&result_image.save(outfile)&&
if&__name__&==&'__main__':&&
&&&&filename&=&sys.argv[1]&&
&&&&plist_filename&=&filename&+&'.plist'&&
&&&&png_filename&=&filename&+&'.png'&&
&&&&if&(os.path.exists(plist_filename)&and&os.path.exists(png_filename)):&&
&&&&&&&&gen_png_from_plist(&plist_filename,&png_filename&)&&
&&&&else:&&
&&&&&&&&print&"make&sure&you&have&boith&plist&and&png&files&in&the&same&directory"&&
windows7 下相关python配置:
1. 安装python2.7.3
2. 在此处下载 安装 (这是最简洁的方式,已经编译好png,zip等处理)&
&https://pypi.python.org/pypi/Pillow/2.2.1#downloads
http://download.csdn.net/detail/liuheng5465
/python/python2-split-plist-spritesheet.html
 昨天写了Zwoptex生成精灵表,有合就有分,能不能把合成的文件再原模原样的还原回来,哈哈&&于是,今天利用闲暇的时间想一个问题:plist是用xml格式的,强大的python中的PIL(Python Imaging Library)可以处理各种图片,更不用说png图片了。  昨天分析过plist,除了一个名字外,今天还能用上的还有两个属性,原始的文件的尺寸大小(这必须得要)和纹理在精灵表中的位置和大小,因为对xml的操作不太多,只是读取数据,就选用轻量级的ElementTree,把从xml解析出来的字符串数据转换成int类型,这就得到了图片属性的真实数据,这在精灵表上复制那个区域内的图片,然后在粘贴到新建的图片里面,哈哈,这样就搞定了。  在操作的时候会用到PIL库,。  大概的思路是说出来啦,最实在的还是把代码粘贴出来,运行一下看看:
import os,Image,sys
from xml.etree import ElementTree
filenames=os.listdir(os.getcwd())
if len(sys.argv)==2:
&&&&filepath=sys.argv[1]
&&&&for filename in filenames:
&&&&&&&&if (filename==filepath+'.png') or (filename==filepath+'.plist'):
&&&&&&&&&&&&i +=1
&&&&if i==0:
&&&&&&&&print("No such file or directory!")
&&&&elif i==1:
&&&&&&&&print("Both .png and .plist are need!")
&&&&&&&&treeroot=ElementTree.parse(filepath+'.plist').getroot()
&&&&&&&&image=Image.open(filepath+'.png')&
&&&&&&&&sizelist=(0,0)
&&&&&&&&for dict1 in treeroot:
&&&&&&&&&&&&for index1,item1 in enumerate(dict1):
&&&&&&&&&&&&&&&&if item1.text=='frames':&
&&&&&&&&&&&&&&&&&&&&i=0
&&&&&&&&&&&&&&&&&&&&dict2 = dict1[index1+1]
&&&&&&&&&&&&&&&&&&&&while i&len(dict2):
&&&&&&&&&&&&&&&&&&&&&&&&print("name:"+dict2[i].text)
&&&&&&&&&&&&&&&&&&&&&&&&picname=dict2[i].text
&&&&&&&&&&&&&&&&&&&&&&&&dict3 = dict2[i+1]
&&&&&&&&&&&&&&&&&&&&&&&&for index3,item3 in enumerate(dict3):
&&&&&&&&&&&&&&&&&&&&&&&&&&&&if item3.text=='spriteSourceSize':
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&size=dict3[index3+1].text
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&sizelist = size.replace('{','').replace('}','').split(',')
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&sizelist=(int(sizelist[0]),int(sizelist[1]));
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&if item3.text=='textureRect':
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&rect=dict3[index3+1].text
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&rectlist = rect.replace('{','').replace('}','').split(',')
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&box=(int(rectlist[0]),int(rectlist[1]),int(rectlist[0])+int(rectlist[2]),int(rectlist[1])+int(rectlist[3]))
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&print("size:")
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&print(sizelist)
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&print("onBig:")
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&print(box)
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&xim=image.crop(box)
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&xxim=Image.new('RGB',sizelist,(255,255,255))
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&box1=((sizelist[0]-box[2]+box[0])/2,(sizelist[1]-box[3]+box[1])/2,(sizelist[0]+box[2]-box[0])/2,(sizelist[1]+box[3]-box[1])/2)
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&print("onNew:")
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&print(box1)
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&xxim.paste(xim,box1,mask=0)
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&if os.path.isdir(filepath):
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&pass
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&else:
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&os.mkdir(filepath)
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&outfile=filepath+'/'+picname
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&print("newPath:"+outfile)
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&xxim.save(outfile)
&&&&&&&&&&&&&&&&&&&&&&&&i +=2
&&&&print("Please enter only one parameter!")
里面的print比较多,因为怕出错了不好找,就写几步,print出来看看数据对不对。  复制这段代码,保存,然后在终端写:python xx.py file(就是想分割的文件名,不加后缀)。  本人运行环境:Mac OSX10.7,python 2.7.3,PIL 1.1.7,完美通过!  
/archives/275
参考网址1:
结果:doesn&t work on python 2.7,报错&& &&==&作者已经修正该问题,有兴趣的朋友可以进入以上链接尝试他的方案。&&&==&该文的方案适用于由Zwoptex制作的png+plist,有兴趣的朋友请移步。
参考网址2:
结果:不够完善,兼容性不好,于是我又经过了一点修改后,终于在python 2.7下成功。如果你的大图是pvr,需要先用Texture Packer转成png。
下面记录一下步骤:
安装PIL(Python Imaging Library)附上Mac上自己编译安装PIL的步骤:1.在xcode中安装命令行工具,如果你尚未安装过的话2.curl -O -L http://effbot.org/media/downloads/Imaging-1.1.7.tar.gz3.tar -xzf Imaging-1.1.7.tar.gz4.cd Imaging-1.1.75.python setup.py build6.sudo python setup.py install
保存以下内容至split_png_plist.py
#! /usr/lical/bin/python
import os,Image,sys
from xml.etree import ElementTree
def tree_to_dict(tree):
for index, item in enumerate(tree):
if item.tag == 'key':
if tree[index+1].tag == 'string':
d[item.text] = tree[index + 1].text
elif tree[index + 1].tag == 'true':
d[item.text] = True
elif tree[index + 1].tag == 'false':
d[item.text] = False
elif tree[index+1].tag == 'dict':
d[item.text] = tree_to_dict(tree[index+1])
def gen_png_from_plist(plist_filename, png_filename):
file_path = plist_filename.replace('.plist', '')
big_image = Image.open(png_filename)
root = ElementTree.fromstring(open(plist_filename, 'r').read())
plist_dict = tree_to_dict(root[0])
to_list = lambda x: x.replace('{','').replace('}','').split(',')
for k,v in plist_dict['frames'].items():
print "-----start\n----------"
rectlist = to_list(v['frame'])
print rectlist, "--------rectlist"
width = int( rectlist[3] if v['rotated'] else rectlist[2] )
height = int( rectlist[2] if v['rotated'] else rectlist[3] )
print width,height,"----width,height"
int(rectlist[0]),
int(rectlist[1]),
int(rectlist[0]) + width,
int(rectlist[1]) + height,
# bos is start & end point
print box,"-----_box-"
print v['rotated'], "---rotated"
sizelist = [ int(x) for x in to_list(v['sourceSize'])]
rect_on_big = big_image.crop(box)
result_image = Image.new('RGBA', sizelist, (0,0,0,0))
result_box=(
( sizelist[0] - width )/2,
( sizelist[1] - height )/2,
( sizelist[0] + width )/2,
( sizelist[1] + height )/2
result_image.paste(rect_on_big, result_box, mask=0)
if v['rotated']:
result_image = result_image.rotate(90)
if not os.path.isdir(file_path):
os.mkdir(file_path)
outfile = (file_path+'/' + k).replace('gift_', '')
print result_box,"-----result_box-"
print outfile, "generated"
# result_image.save(outfile)
if v['rotated']:
rect_on_big = rect_on_big.rotate(90)
if not os.path.isdir(file_path):
os.mkdir(file_path)
outfile = (file_path+'/' + k).replace('gift_', '')
if not outfile.lower().endswith('.png'):
#PIL fails if no extension
outfile += ".png";
print "saving:" +
rect_on_big.save(outfile);
print "saved:" +
if __name__ == '__main__':
filename = sys.argv[1]
plist_filename = filename + '.plist'
png_filename = filename + '.png'
if (os.path.exists(plist_filename) and os.path.exists(png_filename)):
gen_png_from_plist( plist_filename, png_filename )
print "make sure you have boith plist and png files in the same directory"
将该py文件和你的xxx.png、xxx.plist放在同一目录下,终端中运行:python split_png_plist.py xxx
一切顺利的话,当前目录下会生成名为xxx的目录,里面就是分割出来的各png小图
阅读(...) 评论()1、安装 TexturePacker
2、安装python
3、安装Pillow-2.1.0.win-amd64-py2.7.exe &其他下载https://pypi.python.org/simple/pillow/
2、PVR转PNG.bat的使用
把 xx.plist和xx.pvr.ccz 文件放在工具目录下,直接双击“PVR转PNG.bat”
批处理文件,如果成功的话,在当前目录下就会生成相应的.png文件,这个批处理
可同时转化很多对(xx.plist和xx.pvr.ccz)文件,当然,也有可能失败,
如果失败,我们可以使用另一种方式转化,直接使用TexturePacker工具。
3、使用TexturePacker工具把xx.plist和xx.pvr.ccz转化为.png
& & 1. TexturePacker中有个PVR Viewer工具,我们可以直接使用这个工具
& & & &进行转化。
& & 2. 使用PVR Viewer工具打开我们要转化的文件,然后点击File下的Save As,
& & 保存为.png文件即可,保存时把文件的后缀名添加上.png即可。
4、使用split.py脚本 - 将Texture Packer制作的.pvr.ccz和.plist文件还原为多个原图
& & 1. split.py脚本只能通过.png和.plist文件还原,而不能直接通过.pvr.ccz和.plist文件,
& & 所以需要根据2和3中的方法把xx.plist和xx.pvr.ccz转化为.png
& & 2. 在Dos命令行模式下,进入脚本存放目录,同时需要把.png和.plist文件也放在这个
& & 目录下,而且要确保.png和.plist文件的文件名相同(例:mm.png和mm.plist),
& & 然后执行split.py脚本,传入参数(例:上面的mm),然后执行即可。
& & 3. 当然也有可能不成功,因为split.py脚本是通过分析.plist文件,然后对
& & &.png文件进行切割,保存,如果失败,可以检查一下.plist文件是否正确。
split.py脚本
把所有需要转化的.pvr.ccz和.plist文件放到和脚本相同目录下,点击脚本运行即可。
原文出处:http://blog.csdn.net/tianxiawuzhei/article/details/
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:29060次
排名:千里之外
原创:25篇
转载:27篇
(1)(1)(3)(5)(2)(2)(1)(1)(1)(2)(1)(8)(2)(1)(5)(7)(1)(8)Table of Contents
Tested with cocos2dx:
Introduction
Being Creative
From Programmer To Artist
when we release new chapters or use the .
DevelopersTexturePacker是一款把若干资源图片拼接为一张大图的工具。网页设计师前台制作css的时候,为了提高载入速度,往往把很多小图拼接成一张大图,一次载入,减少I/O,提高速度。这个好懂吧。
所以不管怎么样,&拼大图&这个流程不可少。文艺青年说他用Photoshop 推荐用TexturePacker,拼图更专业。
TexturePacker这个词从字面来说就是Texture(纹理) + Packer(打包)。当然TexturePacker的功能远远不止这些,你还可以用它来生成程序所需的框架,如Cocos2d,Corona(TM) SDK ,Gideros ,Sparrow ,LibGDX,LimeJS 和Moai等。
TexturePacker一键生成CSS sprites:
就标题来看,其实是贬低了TexturePacker的功能的,因为TexturePacker远远不止用于生成CSS sprites,只不过对于小编来说,也就只能用这个功能而已。
CSS sprites是TexturePacker一大功能,你只要将所有网页小图片添加到TexturePacker,然后设置文件导出格式为css,即可快速生成一张整合后的图片和css文件,这对网页前端设计师来说是不可多得的高效率工具。
什么是CSS sprites:
先来简单介绍一下CSS sprites,这是干嘛用的。众所周知,我们在设计网页时,会有很多很多的网页小元素,例如导航按钮,社交图标,网站背景图等等。一般情况下,这些图片都是单独形式存在的,对于每一张图片,在网页加载时都属于独立的http请求。但使用CSS sprites,则会将所有的小图片整合到一张图片中,网页加载只需要对一张图片进行请求,CSS再通过坐标的形式定位每一个小图片显示出来。这样有什么好处呢,个人认为最大的好处是,大大减少http请求数,提高网页加载速度。
TexturePacker神马优点:
&TexturePacker有windows版。不是所有人都有条件用水果。
&TexturePacker有免费功能限制版。(你若要求不太高,TexturePacker够你用)
&TexturePacker支持pvr格式。
&TexturePacker支持命令行集成。
&TexturePacker的兄弟软件PhysicsEditor同样是很好的物理建模工具。
TexturePacker怎么用?
1、打开TexturePacker
2、我的图片资源存放在F:\_data\vPuzzle\resource.work,如果你喜欢,你可以把整个文件夹拖到右边的①区,下图是拖进去以后的模样。
3、但是往往我们不想一股脑把所有图片合在一张超大的图中,所以我个人比较喜欢手动添加图片,这样便于控制。
4、我添加了一些图片,并把它们拖到上面图右边的区域
5、ok,该保存了。在data file处填入你要的plist文件路径,在texture format处选择你要的图片格式,在texture file填入你要生成的图片路径。(其他还有很多细节的设定,请尝试体验几次就明白怎么用了)另外,最后,点击菜单条的publish按钮,哦了。之后你可以利用它着手制作一款伟大的游戏了!
认识TexturePacker的界面:
Data Format:导出什么引擎数据,默认cocos2d,下拉列表中有很多,基本常用的引擎都支持了
Data File :导出文件位置(后缀名.plist)
Texture Format:纹理格式,默认png
Image format:图片像素格式,默认RGBA8888...根据对图片质量的需求导出不同的格式
Dithering:抖动,默认NearestNeighbour,(如果图像上面有许许多多的&条条&和颜色梯度变化)将其修改成FloydSteinberg+A
Scale:&让你可以保存一个比原始图片尺寸要大一点、或者小一点的spritesheet。比如,如果你想在spritesheet中加载&@2x&的图片(也即为Retina-display设备或者ipad创建的)。但是你同时也想为不支持高清显示的iphone和touch制作spritesheet,这时候只需要设置scale为 1.0,同时勾选autoSD就可以了。也就是说,只需要美工提供高清显示的图片,用这个软件可以自己为你生成高清和普清的图片。
Algorithm TexturePacker:里面目前唯一支持的算法就是MaxRects,即按精灵尺寸大小排列,但是这个算法效果非常好,因此你不用管它。
Border/shape padding:&即在spritesheet里面,设置精灵与精灵之间的间隔。如果你在你的游戏当中看到精灵的旁边有一些&杂图&的时候,你就可以增加这个精灵之间的间隔。
Extrude:&精灵边界的重复像素个数. 这个与间隔是相对应的--如果你在你的精灵的边边上看到一些透明的小点点,你就可以通过把这个值设设置大一点。
Trim:&通过移除精灵四周的透明区域使之更好地放在spritesheet中去。不要担心,这些透明的区域仅仅是为了使spritesheet里面的精灵紧凑一点。--当你从cocos2d里面去读取这些精灵的时候,这些透明区域仍然在寻里。(因为,有些情况下,你可能需要这些信息来确定精灵的位置)
Shape outlines:&把这个选项打开,那么就能看到精灵的边边。这在调试的时候非常有用。
AddSprite:添加图片Add Folder:根据文件夹添加图片
Publish:导出资源文件(.plist和png)
大众源码网提醒您:TexturePacker-3.0.9-win32.msi是安装包,TexturePackerGUI_crack.exe是破解补丁,安装完后把TexturePackerGUI_crack.exe拷贝到TexturePacker的安装目录下,以后就运行它就OK了。
如果您喜欢本软件,请点击下面的按钮分享给您的朋友们,他们会感激您的。
下载栏目导航
本类下载排行
总下载排行

我要回帖

更多关于 texturepacker key 的文章

 

随机推荐