本文整理汇总了C++中AppDelegate::StartBGMusic方法的典型用法代码示例。如果您正苦于以下问题:C++ AppDelegate::StartBGMusic方法的具体用法?C++ AppDelegate::StartBGMusic怎么用?C++ AppDelegate::StartBGMusic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppDelegate
的用法示例。
在下文中一共展示了AppDelegate::StartBGMusic方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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)]);
//.........这里部分代码省略.........
示例2: 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;
}
示例3: 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;
}