Crash on CCAnimation

When i run the below animation code it crash on simulator. but working fine on Device.

Code:-

 CCSprite* pSprite = CCSprite::create("pic2.png");
    pSprite->setPosition( ccp(size.width/2, size.height/2) );
    this->addChild(pSprite, 0);
    
    
    
    //Animation
    CCAnimation *animate = CCAnimation::create();
    for (int i = 2; i <=7; i++)
    {
        char frameName[128] = {0};
        sprintf(frameName, "pic%d.png", i);
        animate->addSpriteFrameWithFileName(frameName) ;
    }
    
    animate->setDelayPerUnit(0.1f); // This animation contains 3 frames, will continuous 2.8 seconds.
    animate->setRestoreOriginalFrame(true); // Return to the 1st frame after the 3rd frame is played.
    
    CCAnimate *animaction = CCAnimate::create(animate);
    pSprite->runAction(CCSequence::create(CCRepeat::create(animaction, 1),
                                          CCDelayTime::create(2.0f),
                                          CCCallFuncN::create(this, callfuncN_selector(HelloWorld::menuCloseCallback))));

Exactly on ccsequence its crashing. i got this “reference count should greater than 0” with Exc_Bad_acess

I think you are missing a NULL in your runAction statement.

you should do this:

pSprite->runAction(CCSequence::create(CCRepeat::create(animaction, 1),
                                          CCDelayTime::create(2.0f),
                                          CCCallFuncN::create(this, callfuncN_selector(HelloWorld::menuCloseCallback)),NULL));

@slackmoehrie ,

if i dont use NULL, why in device not crashed, in simulator it crashes?

if i used its working fine in both.

I don’t follow. you need NULL… Why? Because that is what the docs say: http://www.cocos2d-x.org/reference/native-cpp/V3.2alpha0/d7/d30/classcocos2d_1_1_sequence.html