Cocos2d-x 分解大图 为 小图 (前提有配置文件)
来源:互联网 发布:五分钟倒计时 js代码 编辑:程序博客网 时间:2024/04/30 09:14
//从大图中截取小图void CpGameScene::getPngFormTexture(const char* texturePath){//载入大图片CCTexture2D *pTexutre2D=CCTextureCache::sharedTextureCache()->addImage(texturePath);//读取pliststring tmpStr;vector<string> altasVec;ifstream tempStream("atlas.txt");while(!(tempStream.eof())){tempStream>>tmpStr;altasVec.push_back(tmpStr);}struct picInfo{string name;float x;float y;float width;float height;};vector<picInfo> picInfoVec;for (UINT i = 0; i < altasVec.size(); i++){picInfo info;info.name="images/"+altasVec[i]+".png";info.width=stringToNum(altasVec[++i]);info.height=stringToNum(altasVec[++i]);info.x=stringToNum(altasVec[++i])*1024;info.y=stringToNum(altasVec[++i])*1024;i+=2;picInfoVec.push_back(info);CCSprite* pSprite=CCSprite::createWithSpriteFrame(CCSpriteFrame::createWithTexture(pTexutre2D,CCRectMake(info.x,info.y,info.width,info.height)));CCPoint p=pSprite->getAnchorPoint();pSprite->setAnchorPoint(ccp(0,0));CCRenderTexture *render=CCRenderTexture::create(pSprite->getContentSize().width,pSprite->getContentSize().height);render->begin();pSprite->visit();render->end();pSprite->setAnchorPoint(p);CCImage* pImage=render->newCCImage(true);pImage->saveToFile(info.name.c_str(),false);}}
配置文件如下:
bg_day 288 512 0.0 0.0 0.28125 0.5bg_night 288 512 0.28515625 0.0 0.28125 0.5bird0_0 48 48 0.0 0.9472656 0.046875 0.046875bird0_1 48 48 0.0546875 0.9472656 0.046875 0.046875bird0_2 48 48 0.109375 0.9472656 0.046875 0.046875bird1_0 48 48 0.1640625 0.9472656 0.046875 0.046875bird1_1 48 48 0.21875 0.6308594 0.046875 0.046875bird1_2 48 48 0.21875 0.6816406 0.046875 0.046875bird2_0 48 48 0.21875 0.7324219 0.046875 0.046875bird2_1 48 48 0.21875 0.7832031 0.046875 0.046875bird2_2 48 48 0.21875 0.8339844 0.046875 0.046875black 32 32 0.5703125 0.40234375 0.03125 0.03125
0 0
- Cocos2d-x 分解大图 为 小图 (前提有配置文件)
- 使用cocos2d-x把TP合成的大图分解成原来的小图
- 提取plist文件中的单图或分解plist大图为小图
- Libgdx TexturePacker大图分割为小图
- cocos2d-x 大图创建帧动画
- 学习开发cocos2d-x 游戏 (前提篇 一)
- cocos2d-x 读取配置文件plist
- 分割一张大图为小图片数组
- 从大图上裁剪小图,把小图设置为button按钮的图片
- cocos2d-x CCRandom_0_1()有BUG.
- 资源大图切成小图
- 小窥cocos2d-x框架
- 小窥cocos2d-x框架
- cocos2d-x 小知识积累
- Cocos2d-x——读取Csv配置文件
- 跟着BOY学习开发cocos2d-x 游戏 (前提篇 一)
- 跟着BOY学习开发cocos2d-x 游戏 (前提篇 一)
- 跟着BOY学习开发cocos2d-x 游戏 (前提篇 一)
- UINavigationBar自定义导航栏背景和按钮
- 算法----序列和的 top N
- HDU2203_亲和串
- C++多线程和消息队列用法
- 几个很好的面试题
- Cocos2d-x 分解大图 为 小图 (前提有配置文件)
- 抵制日货不会对中国经济构成威胁
- Java反射教程
- JS 操作accrss
- 要避免死锁先
- php amqp 消息队列 RabbitMQ 交换器类型 直连 (三)
- 【BZOJ 2818】 gcd
- 五种常用的设计模式
- JSP内置对象的范围和属性