本文整理汇总了C++中Star::getIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ Star::getIndex方法的具体用法?C++ Star::getIndex怎么用?C++ Star::getIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Star
的用法示例。
在下文中一共展示了Star::getIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isLevelEnd
bool PopStar::isLevelEnd()
{
for (int row = 0; row < ROW_NUM; ++row)
{
for (int col = 0; col < COL_NUM; ++col)
{
Star* star = stars[row][col];
if (star == NULL)
{
continue;
}
int checkRow = row + 1;
if (checkRow < ROW_NUM)
{
Star* checkStar = stars[checkRow][col];
if ( checkStar && (star->getIndex() == checkStar->getIndex()) )
{
return false;
}
}
int checkCol = col + 1;
if (checkCol < COL_NUM)
{
Star* checkStar = stars[row][checkCol];
if ( checkStar && (star->getIndex() == checkStar->getIndex()) )
{
return false;
}
}
}
}
return true;
}
示例2: onSelect
void PopStar::onSelect(const SelectStar& selectStar)
{
clearSelectStars();
std::map<int, Star*> checkList;
checkList.insert(std::make_pair(selectStar.row*REVERSE_NUM+selectStar.col, selectStar.star));
int index = selectStar.star->getIndex();
while (!checkList.empty())
{
std::map<int, Star*>::iterator iter;
for (iter = checkList.begin(); iter != checkList.end(); )
{
int row = iter->first/REVERSE_NUM;
int col = iter->first%REVERSE_NUM;
// 分别检查上下左右的格子
if (row < (ROW_NUM-1)) // 上
{
int checkRow = row+1;
Star* temp = stars[checkRow][col];
if (temp && (temp->getIndex() == index) && !temp->isHighLight())
{
checkList.insert( std::make_pair((checkRow)*REVERSE_NUM + col, temp) );
}
}
if (row > 0) // 下
{
int checkRow = row-1;
Star* temp = stars[checkRow][col];
if (temp && (temp->getIndex() == index) && !temp->isHighLight())
{
checkList.insert( std::make_pair((checkRow)*REVERSE_NUM + col, temp) );
}
}
if (col > 0) // 左
{
int checkCol = col-1;
Star* temp = stars[row][checkCol];
if (temp && (temp->getIndex() == index) && !temp->isHighLight())
{
checkList.insert( std::make_pair(row*REVERSE_NUM + checkCol, temp) );
}
}
if (col < (COL_NUM-1)) // 右
{
int checkCol = col+1;
Star* temp = stars[row][checkCol];
if (temp && (temp->getIndex() == index) && !temp->isHighLight())
{
checkList.insert( std::make_pair(row*REVERSE_NUM + checkCol, temp) );
}
}
Star* star = iter->second;
if ((star->getIndex() == index) && !star->isHighLight())
{
star->setHighLight(true);
SelectStar sstar;
sstar.row = row;
sstar.col = col;
sstar.star = star;
selectStars.push_back(sstar);
checkList.erase(iter++);
}
else
{
++iter;
}
}
}
int selectStarNum = selectStars.size();
if (selectStarNum == 1)
{
Star* star = selectStars.begin()->star;
if (star)
{
star->setHighLight(false);
selectStars.clear();
}
gameLayer->onGuiEvent(EVENT_UPDATE_REDUCE_SCORE, 0);
}
else
{
int score = getPopStarDataMgr().getScoreByReduceNum(selectStarNum);
gameLayer->onGuiEvent(EVENT_UPDATE_REDUCE_SCORE, selectStarNum, score);
}
}