我处于一种奇怪的情况,我的应用程序中有一些网络电话,在回调中,我显示Popup
确认。我面临的问题是Popup
没有显示在回调函数中,但是在其他场景中同样的实现工作,但在特定场景中没有。
我认为使用scheduleOnce调用Popup会解决,因为它可以在Main-Thread上运行,但调度程序甚至不会调用该函数。请参阅下面的实施..
void EndGame::joinRematchCallback(cocos2d::Ref *pSender,std::string msg){
printf("\n rematch request received from %s",msg.c_str());
this->msg=msg;
scheduleOnce(schedule_selector(EndGame::showRematchPopup), 0.8f);
}
void EndGame::showRematchPopup(float dt){
Size winSize = Director::getInstance()->getWinSize();
POPUPDATA info;
info.message=this->msg+" asked for Re-Match. Want to Join?";
info.okAction=okAction("YES");
info.cancelAction=cancelAction("NO");
info.type=ALERT;
info.TAG=GameTag::TAG_REMATCH_REQUEST;
Popup *popup = Popup::create();
popup->popupdata=info;
popup->setActionCallback(CC_CALLBACK_2(CommonScreen::popupActionCallback, GameEngine::getInstance()->activeScene));
this->addChild(popup,5000);
popup->createPopup();
}
函数showRematchPopup
从未调用过,但是当我尝试使用下面的代码调用函数时,它会被调用,但我的Popup仍然不能正常工作。
Director::getInstance()->getScheduler()->schedule(schedule_selector(EndGame::showRematchPopup), this, 0.8f,0,0, false);
Popup
可以在所有场景中正常运行,而不是在这里。
非常感谢任何帮助。
感谢。