from pathlib import Path
import ujson
Path('atlas').mkdir(exist_ok=True)
data = ujson.load(open('./spines-atlas.json',encoding='utf-8'))
atlas = data.get('atlas')
for i in atlas:
frames = i.get('frames')
atlas_name = i.get('name')
width = i.get('width')
height = i.get('height')
name = '\n' + atlas_name + '\n'
size = f'size: {width},{height}\n'
_format = 'format: RGBA8888\n'
_filter = 'filter: Linear,Linear\n'
_repeat = 'repeat: none\n'
content = []
for frame in frames:
f_name = frame.get('name')
rotate = ' rotate:' + str(frame.get('rotate', 0))
x = frame.get('x', 0)
y = frame.get('y', 0)
xy = f' xy: {x},{y}\n'
w = frame.get('width', 0)
h = frame.get('height', 0)
_size = f' size: {w},{h}\n'
orig_w = frame.get('orig_width', 0)
orig_h = frame.get('orig_height', 0)
orig = f' orig: {orig_w},{orig_h}\n'
offx = frame.get('offx', 0)
offy = frame.get('offy', 0)
offset = f' offset: {offx},{offy}\n'
index = ' index: -1\n'
content.append(f'{f_name}\n{rotate}\n{xy}{_size}{orig}{offset}{index}')
content = name+size+_format+_filter+_repeat+''.join(content)
file = Path(f"atlas/{Path(atlas_name).with_suffix('.atlas')}").write_bytes(content.encode('utf-8'))
应该没问题了,解密和atlas处理都有了。文件名还原就普通的cocos,还是很标准的