CCAnimation::createWithFrame doesn't take animation name? Here is the fix

It seems CCAnimation missing the corresponding method animationWithFrame:frameCount:delay: from cocos2d-iphone. The usage is kind like:

CCAnimation* anim = [CCAnimation animationWithFrame:animName frameCount:5 delay:0.08f];

Implementing is straightforward as what I did below in cocos2d-x:

CCAnimation* createWithFrame(const char* animationName, int frameCount, float delay)
{
>
char name[128];
CCArray* frames = CCArray::createWithCapacity(count);
for(int i=0;i<frameCount;++i)
{
sprintf(name, “sd.png\0”, animationName, i);
>
CCSpriteFrame* frame = CCSpriteFrameCache::sharedSpriteFrameCache()>spriteFrameByName;
frames
>addObject(frame);
}
>
CCAnimation* animation = CCAnimation::createWithSpriteFrames(frames, delay);
return animation;
}
>

Hope it helps.

Hi, I think these method isn’t needed.
You can use ‘CCAnimation::createWithSpriteFrames’ to achieve that.