这里使用两张图片制作动画
std::string _fullPath = "touch1.png";
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
_fullPath = CCFileUtils::sharedFileUtils()->fullPathForFilename("touch1.png");
#endif
spriteFinger = CCSprite::create(_fullPath.c_str());
CCAnimation* animation = CCAnimation::create();
for (int i = 1; i < 3; i++)
{
char szName[100] = { 0 };
sprintf(szName, "touch%d.png", i);
animation->addSpriteFrameWithFileName(szName);
}
animation->setDelayPerUnit(5.6f / 14.0f);
animation->setRestoreOriginalFrame(true);
animation->setLoops(-1);
CCAnimate *animate = CCAnimate::create(animation);
spriteFinger->runAction(CCSequence::create(animate, animate->reverse(), NULL));
addChild(spriteFinger);