{
Vector<SpriteFrame*> actionList; //精灵帧的容器
///方法一
// SpriteFrame * frame1 = SpriteFrameCache::getInstance()->
// getSpriteFrameByName("hero_fly_1.png");
// SpriteFrame * frame2 = SpriteFrameCache::getInstance()->
// getSpriteFrameByName("hero_fly_2.png");
// actionList.pushBack(frame1);
// actionList.pushBack(frame2);
for (int i = 1; i < 3;i++)
{
/*方法二
char szName[100] = { 0 };
sprintf(szName, "hero_fly_%d.png", i);
SpriteFrame * frame = SpriteFrameCache::getInstance()->
getSpriteFrameByName(szName);*/
//方法三
SpriteFrame * frame = SpriteFrameCache::getInstance()->
getSpriteFrameByName(String::createWithFormat("hero_fly_%d.png",i)->getCString());
actionList.pushBack(frame);
}
///动作一
//0.3秒切换一次
auto animation = Animation::createWithSpriteFrames(actionList, 0.3f);
auto animate = Animate::create(animation); //是一个action
auto repeat = RepeatForever::create(animate);
this->runAction(repeat);
//动画完成后的回调函数
auto animation = Animation::createWithSpriteFrames(actionList, 0.3f);
auto animate = Animate::create(animation);
auto callfunc = CallFunc::create(this, callfunc_selector(Enemy::destory));
auto sequence = Sequence::create(animate,callfunc,NULL);
this->runAction(sequence);
}