使用plist文件创建精灵并执行动画
2013-05-22 15:48
295 查看
欢迎各位童鞋转载,转载请注明出处:http://blog.csdn.net/song_hui_xiang
作者新浪微博:http://weibo.com/u/3168848533
作者腾讯微博:http://t.qq.com/song_huixiang
作者新浪微博:http://weibo.com/u/3168848533
作者腾讯微博:http://t.qq.com/song_huixiang
// sprite->runAction((CCSequence::create(acion1, action2, NULL))); // 当第一个 action1 永久循环时,则第二个 action2 无法执行到。。 如:action1->setLoops(-1); // 当第一个 action1 有循环遍数时,如3遍,则第一个 action1 执行完3遍后再执行action2 bool HelloWorld::init() { CCSize size = CCDirector::sharedDirector()->getWinSize(); CCArray* array = CCArray::create(); array->retain(); //得到SpriteFrame的缓存 CCSpriteFrameCache* spCache = CCSpriteFrameCache::sharedSpriteFrameCache(); spCache->addSpriteFramesWithFile("heartCircleAni.plist"); CCSprite* sprite = CCSprite::create("Icon.png"); sprite->setPosition(ccp(size.width/2, size.height/2)); std::string front = "heartCircleAni_"; std::string back = ".png"; std::string number = ""; std::string name = ""; //将plist中的图片都加载到array中 for (int i = 1; i <= 13; i++) { number = Convert2String(i); name = front + number + back; CCSpriteFrame* frame = spCache->spriteFrameByName(name.c_str()); array->addObject(frame); } //用array中的spriteframe创建一个animation,每帧间隔0.5s CCAnimation* animation = CCAnimation::createWithSpriteFrames(array, 0.5); CCAnimate* animate = CCAnimate::create(animation); CCScaleBy* scale = CCScaleBy::create(2, 5); sprite->runAction(CCRepeatForever::create(CCSequence::create(animate, scale, NULL))); this->addChild(sprite); return true; }
相关文章推荐
- cocos2d-x使用TexturePacker打包图片及使用生成的plist文件创建精灵动画
- 使用plist创建精灵并执行动画
- cocos2d-x 使用plist创建精灵并执行动画
- cocos2d-x使用TexturePacker打包图片及使用生成的plist文件创建精灵动画
- 使用plist创建精灵并执行动画
- mysql必知必会,使用命令行创建数据源,执行create.sql脚本文件,用populate.sql文件填充各个新表
- 使用Xcode创建plist文件和使用
- cocos3.0使用cocostudio动画帧结合地图对象键值创建精灵动画
- cocos2d plist文件使用(在一张大图中放置多个精灵图片)
- 使用ndk工具链创建在安卓机器上的可执行文件
- Cocos2d-x随机-通过pvr.ccz和plist文件创建动画
- iOS开发的一些小技术:让UIImage有缩放功能、控制log的输出、xcode修改文件注释、随机数的使用、在UIImageView 中旋转图像、在Quartz中如何设置旋转点、创建.plist文件并存储
- 【零碎JAVA】使用jar命令创建可执行的jar文件
- cocos2d-x ——用精灵文件创建一个动画
- 使用 UITableView 创建表格应用演练(2)——从plist文件加载并显示数据
- 使用plist创建动画
- 使用C#创建WindowsService(Windows服务):定期执行Dos命令或Bat(批处理)文件
- Cocos2d学习之路三(使用Zwoptex创建精灵表单和CCAnimate动画)
- iPhone开发之.plist文件的创建于使用—— 代码案例 ( 图片浏览器的创建)
- Cocos2d学习之路三(使用Zwoptex创建精灵表单和CCAnimate动画)