我的代码片段如下:
void HelloWorld::gameOver()
{
CCDirector *pDirector=CCDirector::sharedDirector();
pDirector->getTouchDispatcher()->removeAllDelegates();
this->stopAllActions();
this->unscheduleUpdate();
this->unscheduleAllSelectors();
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
auto spriteEndbg1 = CCSprite::create("engbg1136.png");
spriteEndbg1->setPosition(CCPoint(visibleSize.width/2, visibleSize.height/2));
this->addChild(spriteEndbg1, 5);
auto spriteTop = CCSprite::create("gameover.png");
spriteTop->setPosition(CCPoint(visibleSize.width/2, visibleSize.height-200));
this->addChild(spriteTop, 5);
//score
auto scorebg = CCSprite::create("endtextbg.png");
scorebg->setPosition(CCPoint(visibleSize.width/2, visibleSize.height-350));
this->addChild(scorebg, 5);
char *str = new char(5);
sprintf(str, "您的得分为:%d", scodeNum);
std::string strScore = str;
CCLabelTTF* pLabel = CCLabelTTF::create(str, "Arial", 50);
pLabel->setPosition(ccp(origin.x + visibleSize.width/2,
origin.y + visibleSize.height - pLabel->getContentSize().height));
this->addChild(pLabel, 5);
//try again
auto tyrAgainbg = CCSprite::create("endtextbg.png");
tyrAgainbg->setPosition(CCPoint(visibleSize.width/2, 300));
this->addChild(tyrAgainbg, 5);
CCMenuItemFont::setFontName("American Typewriter");
CCMenuItemFont::setFontSize(60);
auto closeItem = CCMenuItemFont::create("ReStart", this,
menu_selector(HelloWorld::restartFn));
closeItem->setPosition(CCPoint(visibleSize.width/2, 300));
auto menu = CCMenu::create(closeItem,NULL);
menu->setPosition(ccp(0,0));
this->addChild(menu, 5);
}
当我的项目运行此功能后出现崩溃
int retVal = UIApplicationMain(argc, argv, nil, @"AppController");
奇怪的是 argv 为空。
堆栈信息如下所示:
有人遇到过这种问题吗?