CCAnimation problem

I want to make animation of sprite:

walkAnim = CCAnimation::create(); walkAnim->setDelayPerUnit(0.1f);
CCSpriteFrame* pFrame; CCRect rect(0, 0, 32, 32); pFrame = CCSpriteFrame::create("hero0.png", rect); walkAnim->addSpriteFrame(pFrame); pFrame = CCSpriteFrame::create("hero1.png", rect); walkAnim->addSpriteFrame(pFrame); pFrame = CCSpriteFrame::create("hero2.png", rect); walkAnim->addSpriteFrame(pFrame); pFrame = CCSpriteFrame::create("hero3.png", rect); walkAnim->addSpriteFrame(pFrame); pFrame = CCSpriteFrame::create("hero4.png", rect); walkAnim->addSpriteFrame(pFrame); pFrame = CCSpriteFrame::create("hero5.png", rect); walkAnim->addSpriteFrame(pFrame); walk = CCAnimate::create(walkAnim);

then i call
sprite->runAction(walk);

and have “corruption of the heap” error;

so while debug every pFrame have
m_pobTexture = 0x00000000 {m_bPVRHaveAlphaPremultiplied=? m_ePixelFormat=? m_uPixelsWide=??? …}
but
m_strTextureFilename = “hero0.png”

Help me, please.

Hi Thanks for this code, it helped me to solve my own problem.

I used a slightly different code than yours, I didn’t used pFrame = CCSpriteFrame::create(“hero0.png”, rect);
but had no error. Maybe the problem is with your files.

here is my working code:

charAnimation = CCAnimation::create( );
charAnimation > setDelayPerUnit;
charAnimation
> setLoops( INFINITY ); // looping the animation, working so far until I closed the iOS simulator (1 hour). if anyone knows a better way, please let me know.

charAnimation > addSpriteFrameWithFileName;
charAnimation
> addSpriteFrameWithFileName( “frame2.png” );
charAnimation > addSpriteFrameWithFileName;
charAnimation
> addSpriteFrameWithFileName( “frame4.png” );

theAnimation = CCAnimate::create( charAnimation );
theAnimation > initWithAnimation;
character = CCSprite::create;
character
> setPosition( ccp( 100, 100 ));

this > addChild;
character
> runAction( theAnimation );

sorry for the format, “it’s my first day”.