本文整理汇总了C++中AppDelegate::GetPercentToNextLevel方法的典型用法代码示例。如果您正苦于以下问题:C++ AppDelegate::GetPercentToNextLevel方法的具体用法?C++ AppDelegate::GetPercentToNextLevel怎么用?C++ AppDelegate::GetPercentToNextLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppDelegate
的用法示例。
在下文中一共展示了AppDelegate::GetPercentToNextLevel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool MultiPriceMatch::init(){
bool bRet = false;
do{
if(!Layer::init()){
break;
}
int currenlevel = 0;
//if (_gamestatus != GAME_START) {
// _gamestatus = GAME_START;
//}
AppDelegate *app = (AppDelegate*)Application::getInstance();
CC_BREAK_IF(!app);
_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();
currenlevel = app->getCurrentGameLevel();
_gametime = GAME_TIME_EASY;
//_zoomin = true;
//saveProductInfo();
CC_BREAK_IF(!loadProductInfo());
_SORT_UINode = CSLoader::createNode(SORT_UINODE_CSB);
CC_BREAK_IF(_SORT_UINode == nullptr);
_SORT_UINode->setTag(SORT_UI_NODE);
this->addChild(_SORT_UINode);
_vec_Price.clear();
_vec_Price_original.clear();
_vec_Price_index.clear();
char strName[20] = LBL_SP_PDX;
char strLabel[20] = IMG_PD_PRICE;
char strBtn[20] = BTN_PD_PRICE;
//string price, price2;
_vec_lblPrice.clear();
_vec_btnPrice.clear();
std::vector <std::string> vec_price;
std::vector <std::string> vec_Price_original;
std::random_device rd1;
std::mt19937 g1(rd1());
std::shuffle(std::begin(_product_list), std::end(_product_list), g1);
for (int i = 0; i < 3; i++){
std::string price = StringUtils::format("%s",_product_list[i].price.c_str());
//log("Before: price for %d is %s",i, price.c_str());
vec_price.push_back(price);
vec_Price_original.push_back(price);
}
//srand(unsigned(time(NULL)));
//std::random_shuffle(vec_price.begin(), vec_price.end());
std::random_device rd;
std::mt19937 g(rd());
std::shuffle(std::begin(vec_price), std::end(vec_price), g);
//auto engine = std::default_random_engine();
//std::shuffle(std::begin(vec_price), std::end(vec_price), engine);
//for (int i = 0; i < 3; i++){
// log("After: price for %d is %s",i, vec_price[i].c_str());
//}
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
if (vec_Price_original[i].compare(vec_price[j].c_str()) == 0){
_vec_Price_index.push_back(j);
}
}
}
for (int i = 0; i < 3; i++){
log("%d", _vec_Price_index[i]);
}
for (int i = 0; i < 3; i++){
log("for %d", i);
strName[5] = LETTER_NUM_1 + i;
strLabel[6] = LETTER_NUM_1 + i;
strBtn[6] = LETTER_NUM_1 + i;
//std::string price = StringUtils::format("%s",_product_list[i].price->getCString());
//add Image
auto sp = dynamic_cast<Sprite*>(_SORT_UINode->getChildByName(strName));
CC_BREAK_IF(sp == nullptr);
sp->setTag(PRODUCT_IMG_1 + i);
//.........这里部分代码省略.........
示例2: 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)]);
//.........这里部分代码省略.........