/usr/lib/python3/dist-packages/glue/formats/cocos2d.py is in glue-sprite 0.13-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | import os
from .base import BasePlistFormat
class Cocos2dFormat(BasePlistFormat):
extension = 'plist'
build_per_ratio = True
@classmethod
def populate_argument_parser(cls, parser):
group = parser.add_argument_group("Cocos2d format options")
group.add_argument("--cocos2d",
dest="cocos2d_dir",
nargs='?',
const=True,
default=os.environ.get('GLUE_COCOS2D', False),
metavar='DIR',
help="Generate Cocos2d files and optionally where")
def get_context(self, ratio, *args, **kwargs):
context = super(Cocos2dFormat, self).get_context(ratio, *args, **kwargs)
ratio_context = context['ratios'][ratio]
data = {'frames': {},
'metadata': {'version': context['version'],
'hash': context['hash'],
'size':'{{{width}, {height}}}'.format(**context['ratios'][ratio]),
'name': context['name'],
'format': 2,
'realTextureFileName': ratio_context['sprite_filename'],
'textureFileName': ratio_context['sprite_filename']
}
}
for i in context['images']:
image_context = i['ratios'][ratio]
rect = '{{{{{abs_x}, {abs_y}}}, {{{width}, {height}}}}}'.format(**image_context)
data['frames'][i['filename']] = {'frame': rect,
'offset': '{0,0}',
'rotated': False,
'sourceColorRect': rect,
'sourceSize': '{{{width}, {height}}}'.format(**image_context)}
return data
|