I have problem using callfuncND_selector(),,


#1

In new version of cocos2d-x, it has been changed to likes bottom.

bool CCCallFunc::initWithTarget(SelectorProtocol* pSelectorTarget) {
if (pSelectorTarget)
{
dynamic_cast<CCObject*>(pSelectorTarget)->retain(); // changed line (before version use pSelectorTarget->selectorProtocolRetain();
}

if (m_pSelectorTarget)
{
dynamic_cast<CCObject*>(m_pSelectorTarget)~~>release; //
}
m_pSelectorTarget = pSelectorTarget;
return true;
}
and My function looks like,

void ActionFactory::callbackSoundAction
{
Book book = Book::sharedBook;
book->playSoundEffect;
}
CCAction
ActionFactory::soundObjectWithActionProperties
{
actionFactory = ActionFactory::sharedActionFactory;
std::cout<< “actionFactory retainCount :” << actionFactory~~>retainCount() << endl;
CCFiniteTimeAction soundAction = CCCallFuncND::actionWithTarget, ap);
return soundAction;
}
CCAction
ActionFactory::soundObjectWithActionProperties(Object object, Propertiesap)
{
actionFactory = ActionFactory::sharedActionFactory();
CCFiniteTimeAction *soundAction = CCCallFuncND::actionWithTarget(actionFactory, callfuncND_selector(ActionFactory::callbackSoundAction), ap);

return soundAction;
}

then it cause error at this line

void CCObject::retain(void)
{
CCAssert(m_uReference > 0, “reference count should greater than 0”); // here

++m_uReference;
}

It was working at version 0.9.2

Can anyone help me?

thanks :slight_smile:


cocos2dx as shared library