资源简介

cocos2dx+JS写的 棋牌 麻将源代码。 客户端+服务器 框架完整,直接可以运行。支持htm5,安卓,IOS。 cocos2dx+JS写的 棋牌 麻将源代码。 客户端+服务器 框架完整,直接可以运行。支持htm5,安卓,IOS。

资源截图

代码片段和文件信息

#!python
import ossys
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 kv 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 (0000))
        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“

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-09-18 07:25  babykylin_scmj-master\
     文件        6148  2017-09-18 07:25  babykylin_scmj-master\.DS_Store
     文件        6158  2017-09-18 07:25  babykylin_scmj-master\README.md
     目录           0  2017-09-18 07:25  babykylin_scmj-master\client\
     文件        1482  2017-09-18 07:25  babykylin_scmj-master\client\.gitignore
     文件          48  2017-09-18 07:25  babykylin_scmj-master\client\README.md
     文件         747  2017-09-18 07:25  babykylin_scmj-master\client\README_copy.md
     目录           0  2017-09-18 07:25  babykylin_scmj-master\client\assets\
     文件         108  2017-09-18 07:25  babykylin_scmj-master\client\assets\anims.meta
     目录           0  2017-09-18 07:25  babykylin_scmj-master\client\assets\anims\
     文件        1594  2017-09-18 07:25  babykylin_scmj-master\client\assets\anims\angry.anim
     文件          88  2017-09-18 07:25  babykylin_scmj-master\client\assets\anims\angry.anim.meta
     文件         870  2017-09-18 07:25  babykylin_scmj-master\client\assets\anims\dingque_tuijian.anim
     文件          88  2017-09-18 07:25  babykylin_scmj-master\client\assets\anims\dingque_tuijian.anim.meta
     文件         939  2017-09-18 07:25  babykylin_scmj-master\client\assets\anims\fennu.anim
     文件          88  2017-09-18 07:25  babykylin_scmj-master\client\assets\anims\fennu.anim.meta
     文件        1601  2017-09-18 07:25  babykylin_scmj-master\client\assets\anims\guafeng.anim
     文件          88  2017-09-18 07:25  babykylin_scmj-master\client\assets\anims\guafeng.anim.meta
     文件         616  2017-09-18 07:25  babykylin_scmj-master\client\assets\anims\han.anim
     文件          88  2017-09-18 07:25  babykylin_scmj-master\client\assets\anims\han.anim.meta
     文件         618  2017-09-18 07:25  babykylin_scmj-master\client\assets\anims\happy.anim
     文件          88  2017-09-18 07:25  babykylin_scmj-master\client\assets\anims\happy.anim.meta
     文件        1597  2017-09-18 07:25  babykylin_scmj-master\client\assets\anims\huaixiao.anim
     文件          88  2017-09-18 07:25  babykylin_scmj-master\client\assets\anims\huaixiao.anim.meta
     文件        1258  2017-09-18 07:25  babykylin_scmj-master\client\assets\anims\jiong.anim
     文件          88  2017-09-18 07:25  babykylin_scmj-master\client\assets\anims\jiong.anim.meta
     文件        2402  2017-09-18 07:25  babykylin_scmj-master\client\assets\anims\lihai.anim
     文件          88  2017-09-18 07:25  babykylin_scmj-master\client\assets\anims\lihai.anim.meta
     文件        1297  2017-09-18 07:25  babykylin_scmj-master\client\assets\anims\nv_idle.anim
     文件          88  2017-09-18 07:25  babykylin_scmj-master\client\assets\anims\nv_idle.anim.meta
     文件        1848  2017-09-18 07:25  babykylin_scmj-master\client\assets\anims\play_gang.anim
............此处省略2436个文件信息

评论

共有 条评论