cocos合图脚本

require("utils")
require("cfg")

local svn_root = '../../../wly2_lua_svn/美术/res_project/animation/'
local set = {"effect", "soldier"}

print('更新' .. svn_root)
os.execute('svn up ' .. svn_root)

for k, v in ipairs(set) do
    local root = svn_root .. v .. "/"
    local dest_path = PROJECT_PATH .. "res/animation/" .. v .. "/"

    local copy_dir = svn_root .. v .. '_copy'
    os.execute('rm -rf ' .. svn_root .. v .. '_copy')
    os.execute('mkdir ' .. svn_root .. v .. '_copy')

    for ani_f in lfs.dir(root) do
        if ani_f ~= "." and ani_f ~= ".." and ani_f ~= ".DS_Store" and isDir(root .. ani_f) then
            os.execute('mkdir ' .. svn_root .. v .. '_copy/' .. ani_f)

            local file_path = root .. ani_f
            local copy_file_path = svn_root .. v .. '_copy/' .. ani_f
            for child_f in lfs.dir(file_path) do
                if child_f ~= "." and child_f ~= ".." and child_f ~= ".DS_Store" then
                    local src_file = file_path .. '/' .. child_f
                    local dst_file = copy_file_path .. '/' .. ani_f .. '_' .. child_f
                    print('copy file', src_file, dst_file)
                    os.execute(string.format('cp -i %s %s', src_file, dst_file))
                end
            end

            if isExist(file_path .. '.txt') then
                os.execute(string.format('cp -r %s %s', file_path .. '.txt', svn_root .. v .. '_copy/'))
            end
        end
    end
end


for k, v in ipairs(set) do
    local root = svn_root .. v .. '_copy' .. "/"
    local dest_path = PROJECT_PATH .. "res/animation/" .. v .. "/"

    os.execute('rm -rf ' .. dest_path)
    for f in lfs.dir(root) do
        if f ~= "." and f ~= ".." and f ~= ".DS_Store" and isDir(root .. f) then
            local file_path = root .. f
            local dest_file = dest_path .. f
            --force-squared
            --max size 16384
            local cmd = string.format('TexturePacker %s --sheet %s.png --data %s.plist --format cocos2d --texture-format %s --algorithm MaxRects --trim-mode Trim --opt RGBA8888 --max-size 4096', file_path, dest_file, dest_file, PNG_FORMAT)
            cmd = cmd .. ';' .. "pngquant -f --ext .png --quality 10-90 --speed 1 " .. dest_file .. ".png"
            os.execute(cmd)

            if isExist(file_path .. '.txt') then
                os.execute(string.format('cp -r %s %s', file_path .. '.txt', dest_path))
            end
        end
    end
end

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值