I am trying to create an animation but when I run the application I face this error:
libc(2406): Fatal signal 11 (SIGSEGV) at 0x00000014 (code=1), thread 2420 (Thread-144)
this is he code :
Sprite *s;
SpriteFrameCache::getInstance()->addSpriteFramesWithFile("sprites.plist");
auto testBatchNode = SpriteBatchNode::create("sprites.png");
this->addChild(testBatchNode);
s = (Sprite *)Sprite::createWithSpriteFrameName("slice01.png");
s->setPosition(ccp(Utils::s().width / 2, Utils::s().height / 2));
s->setScale(Utils::getScale());
s->stopAllActions();
auto animation = CCAnimation::create();
for (int i = 1; i <= 8; i++){
char szName[100] = { 0 };
sprintf(szName, "slice%01d.png", i);
CCLOG("%s",szName);
animation->addSpriteFrame(CCSpriteFrameCache::getInstance()->spriteFrameByName(szName));
}
animation->setDelayPerUnit(0.1f);
s->runAction(CCAnimate::create(animation));
testBatchNode->addChild(s);
and here is my Class.
I dont know why, but the problem comes out of “s->runAction(CCAnimate::create(animation));”
when I comment it out, I dont get any errors and obviously no animations too!
Am I creating the animation right?
should the animation be on an specific layer ?