cocos2d-x之TexturePacker使用
2013-05-25 20:26
344 查看
TexturePacker用来把大量图片批量导入,简化开发,直接贴代码
用来生成plist的原始图为A1_0.png到A1_3.png
用来生成plist的原始图为A1_0.png到A1_3.png
CCSize size = CCDirector::sharedDirector()->getWinSize(); //获得屏幕的尺寸 CCArray* pArray = CCArray::createWithCapacity(4); CCSpriteFrameCache* pCache = CCSpriteFrameCache::sharedSpriteFrameCache(); //获得SpriteFrame的缓存 pCache->addSpriteFramesWithFile("attack.plist"); CCSprite* pSprite = CCSprite::createWithSpriteFrameName("A1_0.png"); //用attack.plist中的第一张图片名字创建一个精灵 pSprite->setPosition(ccp(size.width/2,size.height/2)); //设置精灵的坐标 char name[20]; for(int i=0; i<4; i++) //将plist中的图片都加载,放到array中 { sprintf(name, "A1_%d.png", i); CCSpriteFrame* pframe = pCache->spriteFrameByName(name); pArray->addObject(pframe); } CCAnimation* pAnimation = CCAnimation::createWithSpriteFrames(pArray,0.2f); //用array中的spriteframe创建一个animation,每帧间隔0.2s CCAnimate* panimate = CCAnimate::create(pAnimation); pSprite->runAction(CCRepeatForever::create(panimate)); this->addChild(pSprite);
相关文章推荐
- Cocos2d-x TexturePacker的使用
- Cocos2d-x TexturePacker的使用
- 1.在cocos2d里面如何使用texture-packer和像素格式来优化spritesheet.html
- Cocos2d-X 安卓中禁止锁屏,音量调节,TexturePacker文件在函数中的具体使用
- cocos2d-x for wp之TexturePackerGUI工具使用
- cocos2d-x之texturepacker的使用
- (转) TexturePacker 3.0 使用教程
- TexturePacker 3.0 使用教程
- Cocos2d-x中的 CCSpriteFrameCache , CCTextureCache的使用
- 开篇&TexturePacker打出图集给UGUI使用
- Unity3d NGUI的使用(四)(TexturePacker与UIAtlas生成prefabs)
- TexturePacker打包成的 plist文件的使用
- Cocos2d-x + CocosBuilder + TexturePacker 批处理资源生成(Only for windows)
- TexturePacker(图片打包工具)使用教程---初级篇
- Cocos2D-x , CCTextureCache的多线程加载原理和使用方法
- 【iOS-Cocos2d游戏开发之十七】灵活使用精灵可视区域(TextureRect)与锚点(anchorPoint),并结合可视区域与锚点制作进度条!
- Cocos2d下TexturePacker2.3版会给iphone, ipad通用版带来的问题
- 【iOS-Cocos2d游戏开发之十七】灵活使用精灵可视区域(TextureRect)与锚点(anchorPoint),并结合可视区域与锚点制作进度条!
- Cocos2dx使用 TexturePacker导出的.plist
- Cocos2dx使用 TexturePacker导出的.plist