本文整理汇总了C++中AppDelegate::getBGMstatus方法的典型用法代码示例。如果您正苦于以下问题:C++ AppDelegate::getBGMstatus方法的具体用法?C++ AppDelegate::getBGMstatus怎么用?C++ AppDelegate::getBGMstatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppDelegate
的用法示例。
在下文中一共展示了AppDelegate::getBGMstatus方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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.");
}
}
示例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: 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);
}
}
示例4: 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();
}
}
示例5: 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);
}
}
示例6: 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;
}
示例7: 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.");
}
}
示例8: ShowTutorialCallback
void MultiPriceMatch::ShowTutorialCallback(Ref* pSender, ui::Widget::TouchEventType eEventType){
if (eEventType == cocos2d::ui::Widget::TouchEventType::ENDED){
AppDelegate *app = (AppDelegate*)Application::getInstance();
if (app->getBGMstatus() == BGMusic_flag::ON){
app->PlayEffect(SOUND_BUTTON_CLICK);
}
auto scene = TutorialScene::create();
if(scene != nullptr){
TransitionScene *transition = TransitionFade::create(1, scene);
Director::getInstance()->pushScene(transition);
}
}
}
示例9: PlayAnimation
void GameLayer::PlayAnimation(float dt)
{
Armature *armature = dynamic_cast<Armature *>(_rootNode->getChildByTag(888));
if (nAniFlag == 1)
{
armature->setPosition(Vec2(200, 400));
armature->setRotation(270);
nAniFlag = 2;
}
else
{
armature->setPosition(Vec2(800, 200));
armature->setRotation(180);
nAniFlag = 1;
}
armature->getAnimation()->playWithIndex(0, -1, 0);//from the first frame, no loop
AppDelegate* app = (AppDelegate*)Application::getInstance();
if (app->getBGMstatus() == BGMusic_flag::ON)
{
app->PlayEffect(SOUND_ANIMATION);
}
}
示例10: init
//.........这里部分代码省略.........
//Add by Long EOF
//test button
btnMain->addTouchEventListener(CC_CALLBACK_2(MultiPriceMatch::menuKeyCallback, this));
btnQuit->addTouchEventListener(CC_CALLBACK_2(MultiPriceMatch::ShowTutorialCallback, this));
auto btnClr = dynamic_cast<Button*>(_SORT_UINode->getChildByName(BTN_CLEAR));
CC_BREAK_IF(btnClr == nullptr);
btnClr->addTouchEventListener(CC_CALLBACK_2(MultiPriceMatch::btnClear, this));
btnClr->setTitleColor(ccc3(255,248,220));
btnClr->setTitleFontSize(32);
btnClr->setTitleText("CLEAR");
btnClr->setVisible(false);
auto txtClear = dynamic_cast<Text*>(_SORT_UINode->getChildByName("clear"));
txtClear->setVisible(false);
//btnClr->addChild(txtClear);
auto btnSub = dynamic_cast<Button*>(_SORT_UINode->getChildByName(BTN_SUBMIT));
CC_BREAK_IF(btnSub == nullptr);
btnSub->addTouchEventListener(CC_CALLBACK_2(MultiPriceMatch::btnSubmit, this));
btnSub->setTitleColor(ccc3(255,248,220));
btnSub->setTitleFontSize(32);
btnSub->setTitleText("SUBMIT");
btnSub->setVisible(false);
auto txtsubmit = dynamic_cast<Text*>(_SORT_UINode->getChildByName("submit"));
txtsubmit->setVisible(false);
auto txtPrice1 = dynamic_cast<Text*>(_SORT_UINode->getChildByName("price_1"));
auto txtPrice2 = dynamic_cast<Text*>(_SORT_UINode->getChildByName("price_2"));
auto txtPrice3 = dynamic_cast<Text*>(_SORT_UINode->getChildByName("price_3"));
txtPrice1->setVisible(false);
txtPrice2->setVisible(false);
txtPrice3->setVisible(false);
auto lvlbar = dynamic_cast<Sprite*> (_SORT_UINode->getChildByName(LINK_UI_LEVELBAR));
lvlbar->setAnchorPoint(Vec2(0,0.5));
//lvlbar->setPositionX(lvlbar->getPositionX()-lvlbar->getContentSize().width/2);
lvlbar->setScaleX(_fPerToNLvl);
auto btnTips = dynamic_cast<Button*>(_SORT_UINode->getChildByName(LINK_UI_BTN_TIPS));
CC_BREAK_IF(btnTips == nullptr);
btnTips->addTouchEventListener(CC_CALLBACK_2(MultiPriceMatch::ShowHintCallback, this));
auto touchListener = EventListenerTouchOneByOne::create();
touchListener->onTouchBegan = CC_CALLBACK_2(MultiPriceMatch::onTouchBegan, this);
touchListener->onTouchEnded = CC_CALLBACK_2(MultiPriceMatch::onTouchEnded, this);
touchListener->onTouchMoved = CC_CALLBACK_2(MultiPriceMatch::onTouchMoved, this);
touchListener->onTouchCancelled = CC_CALLBACK_2(MultiPriceMatch::onTouchCancelled, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this);
//AppDelegate *app = (AppDelegate*)Application::getInstance();
if (app->iGameMode == MobileGameMode::Theme_Mode){
btnMain->setVisible(false);
//btnSetting->setVisible(false);
//btnVoice->setVisible(false);
btnQuit->setVisible(false);
}
if ( app->getBGMstatus() == BGMusic_flag::ON){
app->StartBGMusic(BGM_GAME);
}
//UserDefault *load = UserDefault::getInstance();
//string sFirstFlip = load->getStringForKey("FIRSTTIME_LINK","0");
//{
// if (atoi(sFirstFlip.c_str()) == 0)
// {
// scheduleOnce(schedule_selector(MultiPriceMatch::loadFirstTutorial), 1.1f);
// load->setStringForKey("FIRSTTIME_LINK", "1");
// }
//}
_bTlEnabled = true;
//-----------------------------------add animation----------------------------------------------------------
ArmatureDataManager::getInstance()->addArmatureFileInfo(ANIMATION_FILE);
Armature *armature = Armature::create(ARMATURE);
CC_BREAK_IF(armature == nullptr);
armature->setAnchorPoint(Vec2(0.5, 0.5));
armature->setVisible(true);
armature->setPosition(Vec2(235, 480));
armature->setTag(888);
auto imgBackFrame = dynamic_cast<Sprite*> (_SORT_UINode->getChildByName(BOARD));
CC_BREAK_IF(imgBackFrame == nullptr);
imgBackFrame->setZOrder(1);
schedule(schedule_selector(MultiPriceMatch::PlayAnimation), 5.0f);
_SORT_UINode->addChild(armature);
//-------------------------------------------------------------------------------------
bRet = true;
}while(0);
return bRet;
}
示例11: init
bool GameLayer::init()
{
iTotalTime = 30;
spCard.clear();//clear it first
if (Layer::init())
{
//-----------------------------------Setup basic settings-----------------------------------------
//get the origin point of the X-Y axis, and the visiable size of the screen
Size visiableSize = Director::getInstance()->getVisibleSize();
Point origin = Director::getInstance()->getVisibleOrigin();
AppDelegate *app = (AppDelegate*)Application::getInstance();
std::string sCSD = app->GetLayoutString();
_rootNode = CSLoader::createNode("res/memory_game/flip" + sCSD + ".csb");
addChild(_rootNode, 1);
SpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("Flip_Level.plist");
thetime = 0;
iFirstCard = -1;
iSecondCard = -1;
//--------------------------------------Setup common gadgets-------------------------------------
_nTlimit = 3; // total tools can be used in each game
_nTlcount = app->getToolsNumberInfo(); // total tools user has
_nLvl = app->GetUserLevel(); //totol tips can be used
_fPerToNLvl = app->GetPercentToNextLevel(); //Percent to next level
_lTtlScore = app->GetUserTotalScore();
auto btnTips = dynamic_cast<::ui::Button*>(_rootNode->getChildByName("btnTips"));
if (btnTips){
btnTips->setTag(2001);
btnTips->addTouchEventListener(CC_CALLBACK_2(GameLayer::touchButton, this));
}
auto button_Main = dynamic_cast<::ui::Button*>(_rootNode->getChildByName("button_Main"));
if (button_Main){
button_Main->setTag(2002);
button_Main->addTouchEventListener(CC_CALLBACK_2(GameLayer::touchButton, this));
}
auto btnTipsTools = dynamic_cast<::ui::Button*>(_rootNode->getChildByName("btnTipsTools"));
if (btnTipsTools){
btnTipsTools->setTag(2003);
btnTipsTools->addTouchEventListener(CC_CALLBACK_2(GameLayer::touchButton, this));
}
if (app->iGameMode == MobileGameMode::Theme_Mode){
//button_Main->setVisible(false);
//btnTips->setVisible(false);
}
auto timerLabel = dynamic_cast<::ui::Text*>(_rootNode->getChildByName("lblTimer"));
auto lvlbar = dynamic_cast<Sprite*> (_rootNode->getChildByName("lv_bar_4"));
lvlbar->setAnchorPoint(Vec2(0, 0.5));
lvlbar->setScaleX(_fPerToNLvl);
if (app->getBGMstatus() == BGMusic_flag::ON)
{
app->StartBGMusic(BGM_GAME);
}
//----------------------------------create a random array------------------------------------
int iDiv = iMaxCard / 2;
int* array1 = new int[iMaxCard / 2];
int* array2 = new int[iMaxCard / 2];
int* unique_array = new int[iMaxCard];
int* array4 = new int[iMaxCard];
int i = 0;
for (i = 0; i<iDiv; i++)
{
array1[i] = i;
array2[i] = i;
}
randomArray(array1, iMaxCard / 2);
randomArray(array2, iMaxCard / 2);
for (i = 0; i<iMaxCard; i++)
{
unique_array[i] = i;
}
for (i = 0; i<iDiv; i++)
{
array4[i] = array1[i];
}
for (i = iDiv; i<iMaxCard; i++)
{
array4[i] = array2[i - iDiv];
}
randomArray(unique_array, iMaxCard);
for (i = 0; i<iMaxCard; i++)
{
unique_array[i] = array4[unique_array[i]];
log("i=%d,%d", i, array4[unique_array[i]]);
}
//setup brick content
srand((unsigned)time(0));//set rand() with real
int random = rand();
sprintf(sFile[0], "%s", sGame[random%MUST_HAVE]);
sprintf(sFile[1], "%s", sGame[MUST_HAVE + int(random % (IMAGE_COUNT - MUST_HAVE) / 3)]);
sprintf(sFile[2], "%s", sGame[MUST_HAVE + int((IMAGE_COUNT - MUST_HAVE) / 3) + int(random % (IMAGE_COUNT - MUST_HAVE) / 3)]);
sprintf(sFile[3], "%s", sGame[MUST_HAVE + int((IMAGE_COUNT - MUST_HAVE) / 3) * 2 + int(random % (IMAGE_COUNT - MUST_HAVE) / 3)]);
//.........这里部分代码省略.........
示例12: touchButton
void GameLayer::touchButton(Object* obj, ::ui::Widget::TouchEventType eventType)
{
auto button = dynamic_cast<::ui::Button*>(obj);
int tag = button->getTag();
if (eventType == ::ui::Widget::TouchEventType::ENDED)
{
AppDelegate *app = (AppDelegate*)Application::getInstance();
app->PlayEffect(SOUND_BUTTON_CLICK);
if (tag == 2001)
{ //Tutorial
auto scene = TutorialScene::create();
if (scene != nullptr){
TransitionScene *transition = TransitionFade::create(1, scene);
Director::getInstance()->pushScene(transition);
}
}
if (tag == 2002)
{ //Home
MsgBoxType m_type = TP_Q_YESNO;
std::string title = MSG_QUIT_TITLE;
std::string msg = MSG_QUIT_MSG;
MsgBox::setMsgBox(m_type, &title, &msg);
auto msgbox = MsgBox::create();
msgbox->setTag(9000);
this->addChild(msgbox, 999);
//Add Event to process
auto btnYes = dynamic_cast<Button*>(msgbox->getChildByTag(MSGBOX_UINODE)->getChildByName("btn_Yes"));// Magnifier Button
auto btnNo = dynamic_cast<Button*>(msgbox->getChildByTag(MSGBOX_UINODE)->getChildByName("btn_No"));// Magnifier Button
btnYes->addTouchEventListener(CC_CALLBACK_2(GameLayer::yesCallback, this));
btnNo->addTouchEventListener(CC_CALLBACK_2(GameLayer::noCallback, this));
}
if (tag == 2003)
{ //AI tips
if (_bTlEnabled == false) return;
_bTlEnabled = false;
if (_nTlimit > 0)
{
if (_nTlcount > 0)
{
_nTlcount--;
//AppDelegate *app = (AppDelegate*)Application::getInstance();
app->setToolsNumberInfo(_nTlcount);
}
else
{
if (_lTtlScore >= 10)
{
showDeductPointEffect("txtScore");
_lTtlScore = _lTtlScore - 10;
//AppDelegate *app = (AppDelegate*)Application::getInstance();
app->UpdateUserScore(0, 10);
}
else return;
}
_nTlimit--;
if (_nTlimit == 0)
{
auto spTips = dynamic_cast<::ui::Button*>(_rootNode->getChildByName("btnTipsTools"));
spTips->setColor(ccc3(84, 84, 84));//not disabled button, so use color instead
}
if (app->getBGMstatus() == BGMusic_flag::ON){
app->PlayEffect(SOUND_TOOL_CLICK);
}
UseTips();
this->scheduleOnce(schedule_selector(GameLayer::enableTools), 2.0f);
}
else return;
}
}
}
示例13: init
//.........这里部分代码省略.........
HttpConnection::v_color_list.push_back(ColorPattern);
ColorPattern.R=247;
ColorPattern.G=147;
ColorPattern.B=78;
HttpConnection::v_color_list.push_back(ColorPattern);
ColorPattern.R=240;
ColorPattern.G=83;
ColorPattern.B=63;
HttpConnection::v_color_list.push_back(ColorPattern);
ColorPattern.R=226;
ColorPattern.G=0;
ColorPattern.B=137;
HttpConnection::v_color_list.push_back(ColorPattern);
ColorPattern.R=158;
ColorPattern.G=61;
ColorPattern.B=150;
HttpConnection::v_color_list.push_back(ColorPattern);
ColorPattern.R=182;
ColorPattern.G=189;
ColorPattern.B=224;
HttpConnection::v_color_list.push_back(ColorPattern);
ColorPattern.R=0;
ColorPattern.G=181;
ColorPattern.B=239;
HttpConnection::v_color_list.push_back(ColorPattern);
ColorPattern.R=0;
ColorPattern.G=108;
ColorPattern.B=163;
HttpConnection::v_color_list.push_back(ColorPattern);
ColorPattern.R=210;
ColorPattern.G=235;
ColorPattern.B=226;
HttpConnection::v_color_list.push_back(ColorPattern);
ColorPattern.R=109;
ColorPattern.G=196;
ColorPattern.B=188;
HttpConnection::v_color_list.push_back(ColorPattern);
ColorPattern.R=88;
ColorPattern.G=185;
ColorPattern.B=71;
HttpConnection::v_color_list.push_back(ColorPattern);
ColorPattern.R=0;
ColorPattern.G=115;
ColorPattern.B=102;
HttpConnection::v_color_list.push_back(ColorPattern);
ColorPattern.R=224;
ColorPattern.G=193;
ColorPattern.B=169;
HttpConnection::v_color_list.push_back(ColorPattern);
ColorPattern.R=190;
ColorPattern.G=135;
ColorPattern.B=105;
HttpConnection::v_color_list.push_back(ColorPattern);
ColorPattern.R=142;
ColorPattern.G=83;
ColorPattern.B=42;
HttpConnection::v_color_list.push_back(ColorPattern);
ColorPattern.R=223;
ColorPattern.G=225;
ColorPattern.B=223;
HttpConnection::v_color_list.push_back(ColorPattern);
ColorPattern.R=121;
ColorPattern.G=125;
ColorPattern.B=130;
HttpConnection::v_color_list.push_back(ColorPattern);
ColorPattern.R=52;
ColorPattern.G=55;
ColorPattern.B=65;
HttpConnection::v_color_list.push_back(ColorPattern);
ColorPattern.R=0;
ColorPattern.G=0;
ColorPattern.B=0;
HttpConnection::v_color_list.push_back(ColorPattern);
HttpConnection::numberOfLoadSprites++;
AppDelegate *app = (AppDelegate*)Application::getInstance();
if ( app->getBGMstatus() == BGMusic_flag::ON){
app->StartBGMusic(BGM_COLLAGE);
}
return true;
}
示例14: touchButton
void GameWin::touchButton(Object* obj,::ui::Widget::TouchEventType eventType)
{
auto button = dynamic_cast<::ui::Button*>(obj);
int tag = button->getTag();
auto node =(Node*) this->getChildByTag(CHILD_TURNTABLE);
if (node != nullptr) {
return;
}
AppDelegate *app = (AppDelegate*)Application::getInstance();
switch(eventType)
{
case ::ui::Widget::TouchEventType::ENDED:
if (app->getBGMstatus() == BGMusic_flag::ON){
app->PlayEffect(SOUND_BUTTON_CLICK);
}
if(tag==1001){ //Continue
if(app->GetNetWorkStatus() != NetworkType::NetworkTypeNone){
std::string sGuid = app->GetUserGuid();
log("GUID is %s", sGuid.c_str());
if (sGuid.length() == 0){ // not a registered user
if (m_iShowRegister == 5){
MsgBoxType m_type = TP_Q_YESNO;;
std::string title="Tweebaa";
std::string msg = MSG_REGISTER_MSG;
std::string info = "\0";
MsgBox::setMsgBox(m_type, &title, &msg, &info);
auto msgbox = MsgBox::create();
auto btnYES = dynamic_cast<Button*>(msgbox->getChildByTag(MSGBOX_UINODE)->getChildByName("btn_Yes"));// Magnifier Button
btnYES->setTitleFontSize(36);
btnYES->setTitleText("YES");
btnYES->addTouchEventListener(CC_CALLBACK_2(GameWin::CallbackRegisterYes, this));
auto btnNO = dynamic_cast<Button*>(msgbox->getChildByTag(MSGBOX_UINODE)->getChildByName("btn_No"));// Magnifier Button
btnNO->setTitleText("NOT NOW");
btnNO->setTitleFontSize(36);
btnNO->addTouchEventListener(CC_CALLBACK_2(GameWin::CallbackRegisterNo, this));
msgbox->setTag(MSGBOX_TAG);
this->addChild(msgbox, 999);
//m_iShowRegister = 0;
break;
}else{
//m_iShowRegister++;
}
}
}
if(m_iCurrentGameID == 1){
auto scene = FindDiffScene::create();
TransitionScene *transition = TransitionFade::create(1, scene);
Director::getInstance()->replaceScene(transition);
}else if(m_iCurrentGameID == 2){
auto scene = ZoomGameScene::create();
TransitionScene *transition = TransitionFade::create(1, scene);
Director::getInstance()->replaceScene(transition);
}else if (m_iCurrentGameID == 3){
auto scene = jigSawScene::create();
TransitionScene *transition = TransitionFade::create(1, scene);
Director::getInstance()->replaceScene(transition);
}else if (m_iCurrentGameID == 4){
auto scene = GameScene::create();
TransitionScene *transition = TransitionFade::create(1, scene);
Director::getInstance()->replaceScene(transition);
}else if (m_iCurrentGameID == 5){
auto scene = PriceMatchScene::create();
TransitionScene *transition = TransitionFade::create(1, scene);
Director::getInstance()->replaceScene(transition);
}else if (m_iCurrentGameID == 6){
auto scene = MultiPriceMatchScene::create();
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);
}
//if(m_iCurrentGameID == 3){
// auto scene = jigSawScene::create();
// //auto scene = LevelSelectLayer::createScene();
// TransitionScene *transition = TransitionFade::create(1, scene);
// Director::getInstance()->replaceScene(transition);
//}
//if(m_iCurrentGameID == 4){
// auto scene = GameScene::create();
// //auto scene = LevelSelectLayer::createScene();
// TransitionScene *transition = TransitionFade::create(1, scene);
// Director::getInstance()->replaceScene(transition);
//}
//if(m_iCurrentGameID == 5){
// auto scene = PriceMatchScene::create();
// //auto scene = LevelSelectLayer::createScene();
// TransitionScene *transition = TransitionFade::create(1, scene);
//.........这里部分代码省略.........
示例15: init
//.........这里部分代码省略.........
Text* lblProductName=dynamic_cast<Text*>(_rootNode->getChildByName("lblProductName"));// (CCLabelTTF*)this->getChildByTag(2001);
lblProductName->setString(m_PrmtPrdct.m_strProductName);
}
auto btnContine = dynamic_cast<Button*>(_rootNode->getChildByName("btnContine"));
btnContine->setTag(1001);
btnContine->addTouchEventListener(CC_CALLBACK_2(GameWin::touchButton, this));
auto btnQuit = dynamic_cast<Button*>(_rootNode->getChildByName("btnQuit"));
btnQuit->setTag(1002);
btnQuit->addTouchEventListener(CC_CALLBACK_2(GameWin::touchButton, this));
auto btnBuyNow = dynamic_cast<Button*>(_rootNode->getChildByName("btnBuyNow"));
btnBuyNow->setTag(1003);
btnBuyNow->addTouchEventListener(CC_CALLBACK_2(GameWin::touchButton, this));
auto btnShare = dynamic_cast<Button*>(_rootNode->getChildByName("btnShare"));
btnShare->setTag(1004);
btnShare->addTouchEventListener(CC_CALLBACK_2(GameWin::touchButton, this));
//Show Total User Score
long l_coins = app->GetUserTotalScore();
char p[20];
sprintf(p, "%ld", l_coins);
string sTotal = p;
iReward = app->getReward();
iStar = app->getStar();
char p1[20];
sprintf(p1, "%ld", iReward);
string sReward = p1;
app->setReward(0,0);
auto lblReward = dynamic_cast<::ui::Text*>(_rootNode->getChildByName("lblReward"));
if (lblReward)
{
lblReward->setString(sReward);
}
auto lblScore = dynamic_cast<::ui::Text*>(_rootNode->getChildByName("lblScore"));
if (lblReward)
{
lblScore->setString(sTotal);
}
//_rootNode->getChildByName("Img_Box")->setVisible(false);
auto imgStar = dynamic_cast<ImageView*>(_rootNode->getChildByName(WIN_STAR_FRAME));
if (imgStar != nullptr) {
_rootNode->getChildByName(WIN_STAR_BOX)->setVisible(false);
if (iStar == 3){
imgStar->loadTexture(WIN_STAR_3);
}
else if (iStar == 2){
imgStar->loadTexture(WIN_STAR_2);
}
else if (iStar == 1){
imgStar->loadTexture(WIN_STAR_1);
}
}
if (app->getBGMstatus() == BGMusic_flag::ON)
{
app->PlayEffect(SOUND_WIN);
}
// start ansyc method load the atlas.png
//Director::getInstance()->getTextureCache()->addImageAsync("MatchBg.png", CC_CALLBACK_1(GameWin::loadingCallBack, this));
/*auto card1 = Sprite::create("match_game_img_1_b.jpg");
// card1->setPosition(Vec2(visiableSize.width / 2 +88 * generalscalefactor, visiableSize.height/2 +50 *generalscalefactor));
//float zoom_x = visiableSize.width *0.5 / card1->getContentSize().width;
// float zoom_y = visiableSize.height * 0.5 / card1->getContentSize().height;
card1->setScale(150/800);
//card1->setScaleY(zoom_y);
Image* image = new Image();
image->s
Texture2D* texture = new Texture2D();
Sprite* sprite = dynamic_cast<Sprite*>(_rootNode->getChildByName("spPromotionImg")); //spPromotionImg
sprite->initWithFile("match_game_img_1_b.jpg");
this->addChild(card1,1,1001);
*/
Sprite* imgBackground = Sprite::create(WIN_BACKGROUND);
imgBackground->setAnchorPoint(Vec2(0, 0));
imgBackground->setPosition(Vec2(0, 0));
this->addChild(imgBackground, -1, 222);
syncFlow();//sync with server
app->PlayEffect(SOUND_GAME_PASS);
return true;
}