cocos2dx3.4 分割plist图片
2024-10-02 08:06:20
如果想要修改一个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(,); 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);
} }
}
}
最新文章
- CentOS 7 环境配置
- 滑动的scrollowview的导航渐变
- 【开源分享:入门到精通ASP.NET MVC+EF6+Bootstrap】从这里开始,一起搭框架(1)开篇介绍
- python3 连接SQLserver
- 【C语言入门教程】4.9 指向指针的指针
- C#/ASP.NET MVC微信公众号接口开发之从零开发(二) 接收微信消息并且解析XML(附源码)
- Python学习教程(learning Python)--3.3.1 Python下的布尔表达式
- 【BZOJ】【1069】【SCOI2007】最大土地面积
- Node Security
- Android 联系人字母排序(仿微信)
- appserv在哪修改服务器名
- 10_Mybatis开发Dao方法——mapper代理实现
- Eclipse启动Tomcat报错,系统缺少本地apr库
- cf C Bear and Prime Numbers
- fis-plus 学习笔记
- Java框架之Spring(四)
- Java中空串和null串的区别
- onceAgain, 这是一个py群的群公告说明
- <;自动化测试方案_4>;第四章、选型标准
- Git- 命令及使用