我有一个EXC_BAD_ACCESS(代码= 1 ...)有时代码= 2使用cocos2d-x。例如,当我这样做时出现此错误:
void HelloWorld::gameLogic(float dt)
{
if (gameState == GameFinish)
{
seaBaseWidth = seaBase->getPositionX();
seaBase->stopAllActions();
CCUserDefault::sharedUserDefault()->setBoolForKey("isHaveHistoryOfSeaBaseWidth", true);
CCUserDefault::sharedUserDefault()->setFloatForKey("basePositionX", seaBaseWidth);
CCUserDefault::sharedUserDefault()->flush();
if (!CCUserDefault::sharedUserDefault()->getBoolForKey("isHaveHistoryScore"))
{
int bestSocre = CCUserDefault::sharedUserDefault()->getIntegerForKey("HighestScore");
if (bestSocre < bird->score)
{
CCUserDefault::sharedUserDefault()->setBoolForKey("isHaveHistorySchore", true);
CCUserDefault::sharedUserDefault()->setIntegerForKey("HighestScore", bird->score);
CCUserDefault::sharedUserDefault()->flush();
}
}
CCUserDefault::sharedUserDefault()->setBoolForKey("isHaveHistoryCurrentSchore", true);
CCUserDefault::sharedUserDefault()->setIntegerForKey("currentScore", bird->score);
CCUserDefault::sharedUserDefault()->flush();
CCDelayTime* tmeDelay = CCDelayTime::create(1.4f);
CCCallFunc* progressIncreaseCall = CCCallFunc::create(this, callfunc_selector(HelloWorld::GameOverScoreScreenStart
));
CCSequence *newSeq = CCSequence::create(tmeDelay, progressIncreaseCall);
this->runAction(newSeq);
}
}
以下是callfunc_selector
的代码:
void HelloWorld::GameOverScoreScreenStart()
{
CCDirector::sharedDirector()->replaceScene(Score::scene());
}
这个方法在CCDictionary.cpp
中崩溃了:
unsigned int CCDictionary::count()
{
return HASH_COUNT(m_pElements);
}
任何人都可以帮我吗?
答案 0 :(得分:0)
尝试
CCSequence *newSeq = CCSequence::create(tmeDelay, progressIncreaseCall, NULL);
而不是
CCSequence *newSeq = CCSequence::create(tmeDelay, progressIncreaseCall);
希望这有帮助。