当前位置: 首页>>代码示例>>C++>>正文


C++ Star::isSelected方法代码示例

本文整理汇总了C++中Star::isSelected方法的典型用法代码示例。如果您正苦于以下问题:C++ Star::isSelected方法的具体用法?C++ Star::isSelected怎么用?C++ Star::isSelected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Star的用法示例。


在下文中一共展示了Star::isSelected方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: genSelectedList

//消除检查
void StarMatrix::genSelectedList(Star* s){
	selectedList.clear();
	deque<Star*> travelList;
	travelList.push_back(s);
	deque<Star*>::iterator it;
	int color = s->getColor();
	for(it= travelList.begin();it != travelList.end();){
		Star* star = *it;
		Star* linkStar = nullptr;
		int index_i = star->getIndexI();
		int index_j = star->getIndexJ();
		//上
		if(index_i-1 >= 0 && (linkStar = stars[index_i-1][index_j]) ){
			if(!linkStar->isSelected()){
				if(star->getColor()==5&&linkStar->getColor()==color){
					travelList.push_back(stars[index_i-1][index_j]);		
				}else if((linkStar->getColor() == star->getColor()||linkStar->getColor()==5)){
					travelList.push_back(stars[index_i-1][index_j]);				
				}
			}
		}
		//下
		if(index_i+1 < ROW_NUM  && (linkStar = stars[index_i+1][index_j]) ){			
			if(!linkStar->isSelected()){
				if(star->getColor()==5&&linkStar->getColor()==color){
					travelList.push_back(stars[index_i+1][index_j]);
				}else if((linkStar->getColor() == star->getColor()||linkStar->getColor()==5)){
					travelList.push_back(stars[index_i+1][index_j]);		
				}
			}
		}
		//左
		if(index_j-1 >= 0 && (linkStar = stars[index_i][index_j-1]) ){
			if(!linkStar->isSelected()){
				if(star->getColor()==5&&linkStar->getColor()==color){
					travelList.push_back(stars[index_i][index_j-1]);
				}else if((linkStar->getColor() == star->getColor()||linkStar->getColor()==5)){
					travelList.push_back(stars[index_i][index_j-1]);	
				}
			}
		}
		//右
		if(index_j+1 < COL_NUM && (linkStar = stars[index_i][index_j+1]) ){				
			if(!linkStar->isSelected()){
				if(star->getColor()==5&&linkStar->getColor()==color){
					travelList.push_back(stars[index_i][index_j+1]);
				}else if((linkStar->getColor() == star->getColor()||linkStar->getColor()==5)){
					travelList.push_back(stars[index_i][index_j+1]);
				}
			}
		}
		if(!star->isSelected()){
			star->setSelected(true);
			selectedList.push_back(star);
		}
		travelList.pop_front();
		it = travelList.begin();
	}
}
开发者ID:joyfish,项目名称:cocos2d,代码行数:60,代码来源:StarMatrix.cpp

示例2: genBombList

//产生炸弹的消除队列
void StarMatrix::genBombList(Star* s){
	selectedList.clear();
	selectedList.push_back(s);
	Star* linkStar = nullptr;
	int index_i = s->getIndexI();
	int index_j = s->getIndexJ();
	//上
	if(index_i-1 >= 0 && (linkStar = stars[index_i-1][index_j]) ){
		if(!linkStar->isSelected())
			selectedList.push_back(stars[index_i-1][index_j]);
	}
	//左上
	if(index_i-1 >= 0 && index_j-1 >= 0&& (linkStar = stars[index_i-1][index_j-1]) ){
		if(!linkStar->isSelected())
			selectedList.push_back(stars[index_i-1][index_j-1]);
	}
	//右上
	if(index_i-1 >= 0 && index_j+1 <= COL_NUM && (linkStar = stars[index_i-1][index_j+1]) ){
		if(!linkStar->isSelected())
			selectedList.push_back(stars[index_i-1][index_j+1]);
	}
	//下
	if(index_i+1 < ROW_NUM  && (linkStar = stars[index_i+1][index_j]) ){
		if(!linkStar->isSelected())
			selectedList.push_back(stars[index_i+1][index_j]);
	}
	//左下
	if(index_i+1 < ROW_NUM  && index_j-1 >= 0 && (linkStar = stars[index_i+1][index_j-1]) ){
		if(!linkStar->isSelected())
			selectedList.push_back(stars[index_i+1][index_j-1]);
	}
	//右下
	if(index_i+1 < ROW_NUM  &&  index_j+1 <= COL_NUM && (linkStar = stars[index_i+1][index_j+1]) ){
		if(!linkStar->isSelected())
			selectedList.push_back(stars[index_i+1][index_j+1]);
	}
	//左
	if(index_j-1 >= 0 && (linkStar = stars[index_i][index_j-1]) ){
		if(!linkStar->isSelected())
			selectedList.push_back(stars[index_i][index_j-1]);
	}
	//右
	if(index_j+1 < COL_NUM && (linkStar = stars[index_i][index_j+1]) ){
		if(!linkStar->isSelected())
			selectedList.push_back(stars[index_i][index_j+1]);
	}
}
开发者ID:joyfish,项目名称:cocos2d,代码行数:48,代码来源:StarMatrix.cpp


注:本文中的Star::isSelected方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。