本文整理汇总了C++中AppDelegate类的典型用法代码示例。如果您正苦于以下问题:C++ AppDelegate类的具体用法?C++ AppDelegate怎么用?C++ AppDelegate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AppDelegate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateFlow
std::string GameWin::updateFlow()
{
AppDelegate *app = (AppDelegate*)Application::getInstance();
std::string strLocal=DataAccess::getParamValue("LocalFlow");
if (strLocal.length() > 0)
{
strLocal = app->base64_xxtea_decode(strLocal);//format:x,x,x,x,x,x,
string::size_type pos;
string sSub;
for (int i = 0; i < 6; i++)
{
pos = strLocal.find(",");
if (pos != string::npos)//found
{
sSub = strLocal.substr(0, pos);
strLocal = strLocal.substr(pos + 1, strLocal.size() - 1);
m_iLocal[i] = atoi(sSub.c_str());
}
else return "\0";//wrong
}
m_iLocal[m_iCurrentGameID - 1] += iReward;
}
else m_iLocal[m_iCurrentGameID - 1] = iReward;
char cFlow[20] = "\0";
std::string strFlow = "";
for (int i = 0; i < 6; i++)
{
if (m_iLocal[i]>0)
{
sprintf(cFlow, "%d:%d,\0", i + 1, m_iLocal[i]);
strFlow += cFlow;
}
}
return strFlow;
}
示例2: menuKeyCallback
void MultiPriceMatch::menuKeyCallback(Ref* pSender, ui::Widget::TouchEventType eEventType){
AppDelegate *app = (AppDelegate*)Application::getInstance();
switch (eEventType) {
case ui::Widget::TouchEventType::BEGAN:
cocos2d::log("touch Began");
break;
case ui::Widget::TouchEventType::ENDED:
cocos2d::log("touch Ended");
if (app->getBGMstatus() == BGMusic_flag::ON){
app->PlayEffect(SOUND_BUTTON_CLICK);
}
MultiPriceMatch::gameover(); //quit the game
break;
case ui::Widget::TouchEventType::MOVED:
cocos2d::log("touch Cancel");
break;
case ui::Widget::TouchEventType::CANCELED:
cocos2d::log("touch Cancel");
break;
default:
cocos2d::log("touch Default");
break;
}
return;
}
示例3: yesCallback
void MultiPriceMatch::yesCallback(cocos2d::Ref* pSender, cocos2d::ui::Widget::TouchEventType type){
if (type == cocos2d::ui::Widget::TouchEventType::ENDED){
AppDelegate *app = (AppDelegate*)Application::getInstance();
if (app->getBGMstatus() == BGMusic_flag::ON){
app->PlayEffect(SOUND_BUTTON_CLICK);
}
_vec_circle.clear();
_vec_circle2.clear();
this->unschedule(schedule_selector(MultiPriceMatch::updateTimeLabel));
//this->unschedule(schedule_selector(FindDiffLayer::updateDragMove));
//AppDelegate *app = (AppDelegate*)Application::getInstance();
// app->SaveGamePassLevel();
app->moveToNextGameLevel();
if (app->iGameMode == MobileGameMode::Theme_Mode)
{
auto scene = ThemeLayer::createScene();
TransitionScene *transition = TransitionFade::create(1, scene);
Director::getInstance()->replaceScene(transition);
}
else
{
auto scene = WelcomeScene::create();
TransitionScene *transition = TransitionFade::create(1, scene);
Director::getInstance()->replaceScene(transition);
}
this->removeChildByTag(9000);
CCLOG("touch ended.");
}
}
示例4: yesCallback
void GameLayer::yesCallback(cocos2d::Ref* pSender, cocos2d::ui::Widget::TouchEventType type)//quit game button
{
if (type == cocos2d::ui::Widget::TouchEventType::ENDED)
{
AppDelegate *app = (AppDelegate*)Application::getInstance();
app->PlayEffect(SOUND_BUTTON_CLICK);
app->moveToNextGameLevel();
this->unschedule(schedule_selector(GameLayer::updateLabels));
this->unschedule(schedule_selector(GameLayer::updateTimeLabel));
if (app->iGameMode == MobileGameMode::Theme_Mode)
{
auto scene = ThemeLayer::createScene();
TransitionScene *transition = TransitionFade::create(1, scene);
Director::getInstance()->replaceScene(transition);
}
else
{
auto scene = WelcomeScene::create();
TransitionScene *transition = TransitionFade::create(1, scene);
Director::getInstance()->replaceScene(transition);
}
this->removeChildByTag(9000);
CCLOG("touch ended.");
}
}
示例5: updateLocalFlow
void GameWin::onSyncCompleted(HttpClient *sender, HttpResponse *response){
if (!response)
{
updateLocalFlow();
return;
}
// You can get original request type from: response->request->reqType
if (0 != strlen(response->getHttpRequest()->getTag()))
{
log("%s completed", response->getHttpRequest()->getTag());
}
int statusCode = response->getResponseCode();
char statusString[64] = {};
sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag());
// _labelStatusCode->setString(statusString);
log("response code: %d", statusCode);
if (!response->isSucceed())
{
log("response failed");
log("error buffer: %s", response->getErrorBuffer());
updateLocalFlow();
return;
}
if (statusCode != 200){
log("response code failed");
log("error buffer: %s", response->getErrorBuffer());
updateLocalFlow();
return;
}
clearLocalFlow();
// dump data
AppDelegate *app = (AppDelegate*)Application::getInstance();
std::vector<char> *buffer = response->getResponseData();
string sXml(buffer->begin(), buffer->end());
pugi::xml_document doc;
pugi::char_t cXml[1024];
strcpy(cXml, sXml.c_str());
pugi::xml_parse_result result = doc.load_string(cXml);
pugi::xml_node nodes = doc.child("mobileAppSyncPoint");
std::string strResult = nodes.child_value("result");
char p[100];
strcpy(p, strResult.c_str());
int iScore = atoi(p);
if (iScore==0)
{
//get TotalPoints
strResult = nodes.child_value("TotalPoints");
app->SaveUserScoreDiff(atoi(strResult.c_str()));
//get TotalTools
strResult = nodes.child_value("TotalTools");
app->SaveUserToolsDiff(atoi(strResult.c_str()));
}
}
示例6: noCallback
void GameLayer::noCallback(cocos2d::Ref* pSender, cocos2d::ui::Widget::TouchEventType type)
{
if (type == cocos2d::ui::Widget::TouchEventType::ENDED)
{
AppDelegate *app = (AppDelegate*)Application::getInstance();
app->PlayEffect(SOUND_BUTTON_CLICK);
this->removeChildByTag(9000);
}
}
示例7: CallbackRegisterNo
void GameWin::CallbackRegisterNo(cocos2d::Ref* pSender, cocos2d::ui::Widget::TouchEventType type){
if (type == cocos2d::ui::Widget::TouchEventType::ENDED) {
AppDelegate *app = (AppDelegate*)Application::getInstance();
if (app->getBGMstatus() == BGMusic_flag::ON){
app->PlayEffect(SOUND_BUTTON_CLICK);
}
switch (m_iCurrentGameID){
case 1:{
auto scene = FindDiffScene::create();
TransitionScene *transition = TransitionFade::create(1, scene);
Director::getInstance()->replaceScene(transition);
}
break;
case 2:{
auto scene = ZoomGameScene::create();
TransitionScene *transition = TransitionFade::create(1, scene);
Director::getInstance()->replaceScene(transition);
}
break;
case 3:{
auto scene = jigSawScene::create();
TransitionScene *transition = TransitionFade::create(1, scene);
Director::getInstance()->replaceScene(transition);
}
break;
case 4:{
auto scene = GameScene::create();
TransitionScene *transition = TransitionFade::create(1, scene);
Director::getInstance()->replaceScene(transition);
}
break;
case 5:{
auto scene = PriceMatchScene::create();
TransitionScene *transition = TransitionFade::create(1, scene);
Director::getInstance()->replaceScene(transition);
}
break;
case 6:
{
auto scene = MultiPriceMatchScene::create();
TransitionScene *transition = TransitionFade::create(1, scene);
Director::getInstance()->replaceScene(transition);
}
}
this->removeChildByTag(9000);
}
}
示例8: btnQuitCallBack
void EventBoard::btnQuitCallBack(Ref* pSender, ui::Widget::TouchEventType eEventType){
if (eEventType == cocos2d::ui::Widget::TouchEventType::ENDED){
AppDelegate *app = (AppDelegate*)Application::getInstance();
app->PlayEffect(SOUND_BUTTON_CLICK);
this->cleanup();
Director::getInstance()->popScene();
}
return;
}
示例9: updateServerAddressLabel
void MainWindow::updateServerAddressLabel() {
AppDelegate* app = AppDelegate::getInstance();
_serverAddressLabel->setText("<html><head/><body style=\"font:14pt 'Helvetica', 'Arial', 'sans-serif';"
"font-weight: bold;\"><p><span style=\"color:#545454;\">Accessible at: </span>"
"<a href=\"" + app->getServerAddress() + "\">"
"<span style=\"color:#29957e;\">" + app->getServerAddress() +
"</span></a></p></body></html>");
_serverAddressLabel->adjustSize();
}
示例10: CallbackRegisterYes
void GameWin::CallbackRegisterYes(cocos2d::Ref* pSender, cocos2d::ui::Widget::TouchEventType type){
if (type == cocos2d::ui::Widget::TouchEventType::ENDED){
AppDelegate *app = (AppDelegate*)Application::getInstance();
if (app->getBGMstatus() == BGMusic_flag::ON){
app->PlayEffect(SOUND_BUTTON_CLICK);
}
GameWin::showRegister();
}
}
示例11: GameFailed
void GameLayer::GameFailed(){
AppDelegate *app = (AppDelegate*)Application::getInstance();
app->moveToNextGameLevel();
this->unschedule(schedule_selector(GameLayer::updateLabels));
this->unschedule(schedule_selector(GameLayer::updateTimeLabel));
auto scene = GameFailed::createScene();
TransitionScene *transition = TransitionFade::create(1, scene);
Director::getInstance()->replaceScene(transition);
}
示例12: PlayAnimation
void MultiPriceMatch::PlayAnimation(float dt)
{
Armature *armature = dynamic_cast<Armature *>(_SORT_UINode->getChildByTag(888));
armature->getAnimation()->playWithIndex(0, -1, 0);//from the first frame, no loop
armature->getAnimation()->setSpeedScale(0.8);
AppDelegate* app = (AppDelegate*)Application::getInstance();
if (app->getBGMstatus() == BGMusic_flag::ON)
{
app->PlayEffect(SOUND_ANIMATION);
}
}
示例13: _tWinMain
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow){
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
g_hInstance = hInstance;
int nRet = 0;
AppDelegate app;
nRet = app.Run();
return nRet;
}
示例14: btnPriceCallback
void MultiPriceMatch::btnPriceCallback(Ref* pSender, ui::Widget::TouchEventType eEventType){
/*if (eEventType != ui::Widget::TouchEventType::BEGAN)*/
CCNode* node = (CCNode*) pSender;
int tag = node->getTag();
bool bSel = false;
for (int i = 0; i < 3;i++){
if (tag == (BTN_PRICE_1 + i)) bSel = true;
}
if (bSel == false) return;
cocos2d::log("button's tag is %d",tag);
auto button = (Button*) _SORT_UINode->getChildByTag(tag);
AppDelegate *app = (AppDelegate*)Application::getInstance();
switch (eEventType) {
case ui::Widget::TouchEventType::BEGAN:
cocos2d::log("btnPriceCallback Began");
button->getTouchBeganPosition();
button->setZOrder(99);
break;
case ui::Widget::TouchEventType::ENDED:
cocos2d::log("btnPriceCallback Ended");
if (app->getBGMstatus() == BGMusic_flag::ON){
app->PlayEffect(SOUND_BUTTON_CLICK);
}
button->setZOrder(1);
MovetoPriceLabel(button);
break;
case ui::Widget::TouchEventType::MOVED:
button->setPosition(button->getTouchMovePosition());
cocos2d::log("btnPriceCallback Moving");
break;
case ui::Widget::TouchEventType::CANCELED:
cocos2d::log("touch Cancel");
button->setZOrder(1);
break;
default:
cocos2d::log("touch Default");
break;
}
return;
}
示例15: noCallback
void MultiPriceMatch::noCallback(cocos2d::Ref* pSender, cocos2d::ui::Widget::TouchEventType type){
if (type == cocos2d::ui::Widget::TouchEventType::ENDED){
AppDelegate *app = (AppDelegate*)Application::getInstance();
if (app->getBGMstatus() == BGMusic_flag::ON){
app->PlayEffect(SOUND_BUTTON_CLICK);
}
//Don't quit the game
this->removeChildByTag(9000);
//enable the touch event
//CallFunc *runCallback = CallFunc::create(CC_CALLBACK_0(FindDiffLayer::resetTouchEvent, this));
//this->runAction(Sequence::create(DelayTime::create(1.0f), runCallback, nullptr));
CCLOG("touch ended.");
}
}