zoukankan      html  css  js  c++  java
  • cocos2dx3.4 分割plist图片

    如果想要修改一个plist文件新打包成plist,而此刻原来的小图都找不到了,那只能把plist分解了,代码如下:

    void UiManage::DecodePlist(string imgPath,string plistPath)
    {
        FileUtils *pFileUtil=FileUtils::getInstance();
        SpriteFrameCache *pFramChace=SpriteFrameCache::getInstance();
        pFramChace->addSpriteFramesWithFile(plistPath,imgPath);
    
        ValueMap plistDic=pFileUtil->getValueMapFromFile(plistPath);
        if (plistDic.find("frames")!=plistDic.end())
        {
            Point pos(0,0);
    
            ValueMap framesDic=plistDic["frames"].asValueMap();
            for (auto it=framesDic.begin();it!=framesDic.end();it++)
            {
                string imgName=it->first;
                string savePath="screenshot/"+imgName;
                //SpriteFrame *pFrame=pFramChace->getSpriteFrameByName(imgName);
                Sprite *pSpr=Sprite::createWithSpriteFrameName(imgName);
                if (pSpr)
                {
                    Size imgSize=pSpr->getContentSize();
                    RenderTexture *pRenderTexture=RenderTexture::create(imgSize.width,imgSize.height);
    
    
                    pRenderTexture->begin();
    
                    pRenderTexture->setAnchorPoint(pos);
                    pSpr->setAnchorPoint(pos);
                    pSpr->setPosition(pos);
                    pSpr->visit();
    
                    pRenderTexture->end();
                    pRenderTexture->saveToFile(savePath,Image::Format::PNG);
                    CCLOG("save img %s",imgName.c_str());
    
                    //CC_SAFE_RELEASE(pRenderTexture);
                    //CC_SAFE_RELEASE(pSpr);
                    pFramChace->removeSpriteFrameByName(imgName);
                }
    
            }
        }
    }
  • 相关阅读:
    阅读笔记--- 04
    站立会议--06个人进度
    站立会议--05 个人
    站立会议---04个人
    场景分析
    站立会议---03个人
    站立会议---02 个人进度
    计算某一天距离今天多少天,多少小时,多少分钟
    改变图片颜色
    手动调整导航控制器中的viewcontroller
  • 原文地址:https://www.cnblogs.com/gamesky/p/4281440.html
Copyright © 2011-2022 走看看