Adam Reed wrote:
I was thinking more along the lines of adding CCSprite objects to your SneakyButton object.
Do you do button->addChild(CCSprite object) at any point before adding the CCNode to your Sprite?
I was tried to link this problem with childs count by adding this line before crashing line:
cocos2d::CCLog("Childs count: %d", button->getChildrenCount());
and whether or not the crash appears after this CCLog, result was the same: button has 0 childes.
After that I went deeper to CCSPrite class and set a new breakpoint:
void CCSprite::addChild(CCNode *pChild, int zOrder, int tag)
CCAssert(pChild != NULL, "Argument must be non-NULL");
if (m_pobBatchNode) // breakpoint here
CCSprite* pChildSprite = dynamic_cast(pChild);
CCAssert( pChildSprite, "CCSprite only supports CCSprites as children when using CCSpriteBatchNode");
CCAssert(pChildSprite->getTexture()->getName() == m_pobTextureAtlas->getTexture()->getName(), "");
//put it in descendants array of batch node
//CCNode already sets isReorderChildDirty_ so this needs to be after batchNode check
CCNode::addChild(pChild, zOrder, tag);
m_bHasChildren = true;
Look to the outer ‘if’ checking: I’ve noticed that crash will appear only when m_pobBatchNode != NULL (we trying to append child to BatchNode as result), else code works fine (CCNode::addChild(pChild, zOrder, tag) is calling). So the only thing what I should to decide is WHY and WHERE m_pobBatchNode initialized.