本文整理汇总了C++中AppDelegate::getCurrentGameLevel方法的典型用法代码示例。如果您正苦于以下问题:C++ AppDelegate::getCurrentGameLevel方法的具体用法?C++ AppDelegate::getCurrentGameLevel怎么用?C++ AppDelegate::getCurrentGameLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppDelegate
的用法示例。
在下文中一共展示了AppDelegate::getCurrentGameLevel方法的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
//.........这里部分代码省略.........
}
return true;
};
for (int col = 0; col < iCols; col++)
{
float x_position = 0.0;
if (col <= iCols / 2)
{
x_position = Director::getInstance()->getVisibleSize().width / 2 - (iCols / 2 - col) * 190 + 80;
}
else
{
x_position = Director::getInstance()->getVisibleSize().width / 2 + (col - iCols / 2) * 190 + 80;
}
for (int row = 0; row < iRows; row++)
{
float y_position = 0.0;
if (row <= iRows / 2)
{
y_position = Director::getInstance()->getVisibleSize().height / 2 + (iRows / 2 - row) * 190 - 80;
}
else
{
y_position = Director::getInstance()->getVisibleSize().height / 2 - (row - iRows / 2) * 190 - 80;
}
auto card1 = Sprite::create("res/memory_game/memory_square.png");
/*
char file[100];
sprintf(file, "%s", sFile[0]);
card1->setDisplayFrame(SpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(file));*/
card1->setPosition(Vec2(x_position + 50, y_position));
if (row == 0 && col == 0){
Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(touchListener1, card1);
}
else{
Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(touchListener1->clone(), card1);
}
int index = row + col*iRows;
this->addChild(card1, 20 + index, 1001 + unique_array[index]);
log("index=%d,z-index=%d,x=%f,y=%f", index, unique_array[index], x_position, y_position);
spCard.pushBack(card1);
auto card2 = Sprite::create("res/memory_game/kuang.png");
card2->setPosition(Vec2(x_position + 50, y_position));
this->addChild(card2, 100 + index, 1001 + unique_array[index]);
log("index=%d,z-index=%d,x=%f,y=%f", index, unique_array[index], x_position, y_position);
}
}
iFirstCard = -1;
iSecondCard = -1;
app->LogAccess("MemoryMatch");
m_iCurrentGameLevel = app->getCurrentGameLevel();
schedule(schedule_selector(GameLayer::updateLabels), 0.01f);
schedule(schedule_selector(GameLayer::updateTimeLabel), 1.0f);
delete[] array1;
delete[] array2;
delete[] unique_array;
delete[] array4;
//Director::sharedDirector()->getScheduler()->scheduleSelector(SEL_SCHEDULE(&GameLayer::loadingCallBack), this, .5f, false);
//-----------------------------------add animation----------------------------------------------------------
auto mastco = dynamic_cast<Sprite *> (_rootNode->getChildByName("Sprite_10"));
//int mastcoZOrder=-1;
if (mastco)
{
//mastcoZOrder = mastco->getZOrder();
mastco->setVisible(false);
}
ArmatureDataManager::getInstance()->addArmatureFileInfo("res/animations/1.3/1.3.ExportJson");
Armature *armature = Armature::create("1.3");
armature->setAnchorPoint(Vec2(0.5, 0.5));
armature->setRotation(270);
armature -> setPosition(Vec2(150,400));
armature->setVisible(true);
armature->setTag(888);
schedule(schedule_selector(GameLayer::PlayAnimation), 5.0f);
_rootNode->addChild(armature);
nAniFlag = 1;
//-------------------------------------------------------------------------------------
_bTlEnabled = true;
return true;
}
else
{
return false;
}
}