Cocos2dx使用callfuncND在Iphone6的模拟器中崩溃

时间:2016-01-14 06:26:51

标签: crash cocos2d-x

我使用cocos2dx 3.9,但代码在Iphone6的模拟器中崩溃但在Iphone4s的模拟器中正确运行

void BattleHeroIconCSBLayer::doEffectValue4(CCNode *node)
{
    CCCallFuncND *remove = CCCallFuncND::create(node, callfuncND_selector(BattleHeroIconCSBLayer::effectNodeCallBack4), (void*)0);
    auto *seq1 = CCSequence::create(MoveBy::create(1.0, ccp(width - node->getContentSize().width, 0)), remove, NULL);
    auto *seq2 = CCSequence::create(FadeIn::create(0.3), DelayTime::create(0.4), FadeOut::create(0.3), NULL);
    auto *spawn = Spawn::create(seq1, seq2, NULL);
    node->runAction(spawn);
}

在BattleHeroIconCSBLayer :: effectNodeCallBack4中,我喜欢这样:

void BattleHeroIconCSBLayer::effectNodeCallBack4(CCNode* pTarget, void* data)
{
    mBuffBack->setVisible(false);
    pTarget->removeFromParentAndCleanup(true);
}

mBuffBack是我的成员变量,我从cocostudio获取它:

mBuffBack = static_cast<Sprite*>(node->getChildByName("mBuffBack"));

但我崩溃了

mBuffBack->setVisible(false);

使用iphone6的模拟器;

有人可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

根据建议,我使用此代码

auto remove = CallFunc::create( CC_CALLBACK_0(BattleHeroIconCSBLayer::effectNodeCallBack4, this, node, (void*)0));

而不是

CCCallFuncND *remove = CCCallFuncND::create(node, callfuncND_selector(BattleHeroIconCSBLayer::effectNodeCallBack4), (void*)0);

它运行正常;但我不知道为什么;