CCAnimation* createAnimationByDirection(HeroDirection direction)
{
CCTexture2D *heroTexture = CCTextureCache::sharedTextureCache()->addImage("hero.png");
CCSpriteFrame *frame0, *frame1, *frame2, *frame3;
frame0 = CCSpriteFrame::createWithTexture(heroTexture, cocos2d::CCRectMake(32*0, 32*direction, 32, 32));
frame1 = CCSpriteFrame::createWithTexture(heroTexture, cocos2d::CCRectMake(32*0, 32*direction, 32, 32));
frame2 = CCSpriteFrame::createWithTexture(heroTexture, cocos2d::CCRectMake(32*0, 32*direction, 32, 32));
frame3 = CCSpriteFrame::createWithTexture(heroTexture, cocos2d::CCRectMake(32*0, 32*direction, 32, 32));
CCArray* animFrames = new CCArray(4);
animFrames->addObject(frame0);
animFrames->addObject(frame1);
animFrames->addObject(frame2);
animFrames->addObject(frame3);
CCAnimation* animation = new CCAnimation();
animation->createWithSpriteFrames(animFrames, 0.2f); //0.2f表示每帧动画间的间隔
animFrames->release();
return animation;
}