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
Try replacing this line -
pSprite->runAction(CCSequence::create(CCRepeat::create(animaction, 1),
CCDelayTime::create(2.0f),
CCCallFuncN::create(this, callfuncN_selector(HelloWorld::menuCloseCallback))));
with
pSprite->runAction(CCSequence::create(CCRepeat::create(animaction, 1),
CCDelayTime::create(2.0f),
CCCallFuncN::create(this, callfuncN_selector(HelloWorld::menuCloseCallback)),NULL));
More information here