CCSize S=CCDirector::sharedDirector()->getWinSize();
//载入动画所需纹理图片
CCTexture2D *texture=CCTextureCache::sharedTextureCache()->addImage("yu01.png");
//切图获取每一帧
CCSpriteFrame *frame0=CCSpriteFrame::createWithTexture(texture, CCRectMake(162*0, 122*0, 160, 120));
CCSpriteFrame *frame1=CCSpriteFrame::createWithTexture(texture, CCRectMake(162*0, 122*1, 160, 120));
CCSpriteFrame *frame2=CCSpriteFrame::createWithTexture(texture, CCRectMake(162*1, 122*0, 160, 120));
CCSpriteFrame *frame3=CCSpriteFrame::createWithTexture(texture, CCRectMake(162*1, 122*1, 160, 120));
CCSpriteFrame *frame4=CCSpriteFrame::createWithTexture(texture, CCRectMake(162*2, 122*0, 160, 120));
CCSpriteFrame *frame5=CCSpriteFrame::createWithTexture(texture, CCRectMake(162*2, 122*1, 160, 120));
CCSpriteFrame *frame6=CCSpriteFrame::createWithTexture(texture, CCRectMake(162*0, 122*2, 160, 120));
CCSpriteFrame *frame7=CCSpriteFrame::createWithTexture(texture, CCRectMake(162*0,122*3, 160, 120));
CCSpriteFrame *frame8=CCSpriteFrame::createWithTexture(texture, CCRectMake(162*1,122*2, 160, 120));
CCSpriteFrame *frame9=CCSpriteFrame::createWithTexture(texture, CCRectMake(162*1,122*3, 160, 120));
CCSprite *sprite03=CCSprite::createWithSpriteFrame(frame0);
sprite03->setPosition(ccp(S.width/2+180,S.height/2-70));
sprite03->setScale(0.4);
addChild(sprite03,3);
CCArray *animFrames=CCArray::createWithCapacity(10);
animFrames->addObject(frame0);
animFrames->addObject(frame1);
animFrames->addObject(frame2);
animFrames->addObject(frame3);
animFrames->addObject(frame4);
animFrames->addObject(frame5);
animFrames->addObject(frame6);
animFrames->addObject(frame7);
animFrames->addObject(frame8);
animFrames->addObject(frame9);
//定义每一帧和动画的间隔时间
CCAnimation *animation=CCAnimation::createWithSpriteFrames(animFrames,0.2f);
//创建动画的Action
CCAnimate *animate=CCAnimate::create(animation);
CCActionInterval* seq= (CCActionInterval*)(CCSequence::create( animate,
CCFlipX::create(false),
animate->copy()->autorelease(),
CCFlipX::create(false),
NULL) );
sprite03->runAction(CCRepeatForever::create( seq ) );