CocosCreator系列教程——如何将.apk解压出来的.atlas文件转成.plist文件

Theodosia ·
更新时间:2024-09-20
· 844 次阅读

CocosCreator系列教程——如何将.apk解压出来的.atlas文件转成.plist文件

因为要用到另外一个项目的图片,但是解压出来以后全是.atlas文件,不能直接使用,然后用ide打开文件看了一下这两个文件的区别,首先是.atlas文件
\n' frame += 'sourceColorRect\n' frame += '{{{{{xy}}},{{{size}}}}}\n' frame += 'sourceSize\n' frame += '{{{size}}}\n' frame += '\n' frames += frame.format(name=data['name'], xy=data['xy'],size=data['size'],rotate=data['rotate'],offset=data['offset']) plist = '\n' plist += '\n' plist += '\n' plist += '\n' plist += 'frames\n' plist += '\n' plist += frames plist += '\n' plist += head + '\n' plist += '\n' plist += '\n' return {'plist': plist,'name': name} # 处理单个altas文件 def handle(path): f = open(path,"r") atlasList = [] for line in f.readlines(): if line.find('.png') != -1: atlasList.append(line); elif len(atlasList) > 0: atlasList[len(atlasList) - 1] += line for atlas in atlasList: data = handleAtlas(atlas) fo = open(os.path.join(os.path.dirname(path) , data['name'] + ".plist"), "w") fo.write(data['plist']) # main get_all('./') for path in result: if path.lower().endswith('.atlas'): handle(path)

使用方法:新建一个parse.py,然后把代码拷进去,把所有的.atlas文件和parse.py放到同一目录下,然后在当前目录输入cmd打开命令窗口,输入:python parse.py运行这个python文件,然后就可以看到所有转换成功的.plist文件了,最后把.plist文件和所对应的.png文件一起拖入项目中就可以直接使用了。
原创文章 11获赞 1访问量 3421 关注 私信 展开阅读全文
作者:liupengxunzhuanshu



apk 教程

需要 登录 后方可回复, 如果你还没有账号请 注册新账号