欢迎各位童鞋转载,转载请注明出处:http://blog.csdn.net/song_hui_xiang
作者新浪微博: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; }