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


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

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


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

示例1: init

bool PopStar::init()
{
	if (!CCNode::init())
	{
		return false;
	}

	if (!gameLayer)
	{
		return false;
	}

	for (int row = 0; row < ROW_NUM; ++row)
	{
		for (int col = 0; col < COL_NUM; ++col)
		{
			int index = (rand() % 5) + 1;
			Star* star = Star::create(index);
			if (star)
			{
				star->setScale(1.5);
				
				star->setPos(ccp(STAR_WIDTH*col + STAR_WIDTH/2, STAR_HEIGHT*row + STAR_HEIGHT/2 + row*20+col*5));
				star->setDestPos(ccp(STAR_WIDTH*col + STAR_WIDTH/2, STAR_HEIGHT*row + STAR_HEIGHT/2));
				gameLayer->addChild(star);

				stars[row][col] = star;
			}
		}
	}

	int level = getPopStarDataMgr().getLevel();
	gameLayer->onGuiEvent(EVENT_UPDATE_LEVEL, level);

	int score = getPopStarDataMgr().getScore();
	gameLayer->onGuiEvent(EVENT_UPDATE_SCORE, score);

	int historyScore = getPopStarDataMgr().getHistoryScore();
	gameLayer->onGuiEvent(EVENT_UPDATE_TOTAL_HISTORY_SCORE, historyScore);

	int historyLevelScore = getPopStarDataMgr().getHistoryLevelScoreByLevel(level);
	gameLayer->onGuiEvent(EVENT_UPDATE_LEVEL_HISTORY_SCORE, historyLevelScore);

	int targetScore = getPopStarDataMgr().getTargetScoreByLevel(level);
	gameLayer->onGuiEvent(EVENT_UPDATE_TARGET_SCORE, targetScore);

	currentState = new GameInitState(this);

	return true;
}
开发者ID:wsmn123123,项目名称:popStar,代码行数:50,代码来源:PopStar.cpp

示例2: onReduce

void PopStar::onReduce()
{
	if (!gameLayer)
	{
		return;
	}

	int num = selectStars.size();
	int score = getPopStarDataMgr().getScore() + getPopStarDataMgr().getScoreByReduceNum(num);
	setScore(score);
	
	StarListIter iter;
	for (iter = selectStars.begin(); iter != selectStars.end(); ++iter)
	{
		gameLayer->removeChild(iter->star);
		stars[iter->row][iter->col] = NULL;
	}
	selectStars.clear();


	// 竖直调整
	for (int row = 0; row < ROW_NUM; ++row)
	{
		for (int col = 0; col < COL_NUM; ++col)
		{
			int tempRow = row;
			Star* star = stars[row][col];
			if (star)
			{
				continue;
			}
			else
			{
				while (!star && (tempRow < ROW_NUM))
				{
					star = stars[tempRow][col];
					if (star)
					{
						break;
					}
					++tempRow;
				}

				if (star)
				{
					stars[row][col] = stars[tempRow][col];
					stars[tempRow][col] = NULL;
				}
			}
		}
	}

	while (isNeedHoriAdjust())
	{
		int endCol = getCheckEndCol();
		for (int col = 0; col <= endCol; ++col)
		{
			if (!stars[0][col])
			{
				for (int i = col; i < endCol; ++i)
				{
					for (int row = 0; row < ROW_NUM; ++row)
					{
						stars[row][i] = stars[row][i+1];
					}
				}

				for (int row = 0; row < ROW_NUM; ++row)
				{
					stars[row][endCol] = NULL;
				}
				
				break;
			}
		}
	}


	// 刷新位置
	for (int row = 0; row < ROW_NUM; ++row)
	{
		for (int col = 0; col < COL_NUM; ++col)
		{
			Star* star = stars[row][col];
			if (star)
			{
				star->setDestPos(ccp(STAR_WIDTH*col + STAR_WIDTH/2, STAR_HEIGHT*row + STAR_HEIGHT/2));
			}
		}
	}

	if (isLevelEnd())
	{
		int num = getLeftStarNum();
		int score = getPopStarDataMgr().getScore() + getPopStarDataMgr().getScoreByLeftNum(num);
		setScore(score);

		int historyScore = getPopStarDataMgr().getHistoryScore();
		if (score > historyScore)
		{
//.........这里部分代码省略.........
开发者ID:wsmn123123,项目名称:popStar,代码行数:101,代码来源:PopStar.cpp


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