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


C++ UserManager::GetStage方法代码示例

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


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

示例1: Init

bool MainScene::Init()
{
	// 获得用户
	UserManager* userMgr = UserManager::getInstance();
	// 启动子弹系统
	BulletManager::getInstance()->startUp("Data/bulletConfig.lua");
	// 启动道具系统
	ItemManager::getInstance()->startUp("Data/itemConfig.lua");
	// 启动飞机系统
	PlaneManager::getInstance()->startUp("Data/planeConfig.lua");
	// 启动特效系统
	EffectManager::getInstance()->startUp("Data/effectConfig.lua");

	// 调整摄像机的z轴位置
	Camera::getInstance()->SetCameraPosition(0, 0, -600);

	// 缓存音效
	AudioManager* audioMgr = AudioManager::getInstance();
	audioMgr->loadSoundForCache("Sound/se/beiji.ogg");
	audioMgr->loadSoundForCache("Sound/se/boom.mp3");
	audioMgr->loadSoundForCache("Sound/se/fly.ogg");
	audioMgr->loadSoundForCache("Sound/se/get_item.mp3");
	audioMgr->loadSoundForCache("Sound/se/missile.mp3");
	audioMgr->loadSoundForCache("Sound/se/own_shoot1.ogg");
	audioMgr->loadSoundForCache("Sound/se/own_shoot2.mp3");
	audioMgr->loadSoundForCache("Sound/se/own_shoot3.ogg");
	audioMgr->loadSoundForCache("Sound/se/se_warning.ogg");

	// 初始化主角飞机
	_own = Own::Create(userMgr->GetOwn());
	_own->SetPosition(0, -150, 0);
	Add(_own, LAYER_PLAYER);

	// 分数
	_scoreText = TextSprite::Create("SCORE:0", "微软雅黑", 16);
	Add(_scoreText);

	// 启动关卡系统
	StageManager::getInstance()->startUp("Data/stage" + to_string(userMgr->GetStage()) + ".lua", this);

	// 启动数据更新函数
	AddUpdateFunc(UpdateFunc::Create(CALLBACK_PARAMETER_1(MainScene::UpdateData, this)));
	EventDispatcher::getInstance()->Add(
		KeyboardListener::Create(
		this, KeyboardFunc::Create(
		CALLBACK_PARAMETER_2(MainScene::onkey, this))));

	return true;
}
开发者ID:Jenovez,项目名称:Frame2D-old,代码行数:49,代码来源:MainScene.cpp

示例2: UpdateData

void MainScene::UpdateData(const float& delta)
{
	// 关卡数据更新
	StageManager::getInstance()->Update(delta);

	vector<Element*> list = GetElementList();
	for (int i = 0; i < list.size(); ++i)
	{
		list.at(i)->SetPositionZ(-list.at(i)->GetOrder() * 2);

		if (list.at(i)->GetOrder() == LAYER_PLAYER_BULLET ||
			list.at(i)->GetOrder() == LAYER_ENEMY_BULLET)
		{
			RECT viewRect = Director::getInstance()->GetViewRect();
			D3DXVECTOR3 viewPos = Camera::getInstance()->GetViewPosition();
			if (Tools::CheckHit_UnInclude(list.at(i),
				viewPos.x - viewRect.right / 2.0f,
				viewPos.y - viewRect.bottom / 2.0f,
				viewPos.x + viewRect.right / 2.0f,
				viewPos.y + viewRect.bottom / 2.0f))
			{
				list.at(i)->SetVisible(false);
			}
		}
		else if (list.at(i)->GetOrder() == LAYER_ENEMY_1 ||
			list.at(i)->GetOrder() == LAYER_ENEMY_2 ||
			list.at(i)->GetOrder() == LAYER_ENEMY_3)
		{
			RECT viewRect = Director::getInstance()->GetViewRect();
			D3DXVECTOR3 viewPos = Camera::getInstance()->GetViewPosition();
			if (list.at(i)->GetPositionY() + (0.5f - list.at(i)->GetAnchorY()) * list.at(i)->GetHeight() <
				viewPos.y + viewRect.bottom / 2.0f &&
				list.at(i)->GetPositionY() - (0.5f - list.at(i)->GetAnchorY()) * list.at(i)->GetHeight() >
				viewPos.y - viewRect.bottom / 2.0f)
			{
				for (int j = 0; j < list.size(); ++j)
				{
					if (list.at(j)->GetOrder() == LAYER_PLAYER_BULLET)
					{
						if (Tools::CheckHit_Circle(list.at(j), list.at(i)) && ((Enemy*)list.at(i))->GetHp() > 0)
						{
							Bullet* bullet = (Bullet*)list.at(j);
							if (bullet->IsCross() == false)
							{
								bullet->Die();
							}
							Enemy* enemy = (Enemy*)list.at(i);
							enemy->SetHp(enemy->GetHp() - bullet->GetAttack());
							enemy->SetBruiseEnable(true);
							
							if (enemy->GetHp() <= 0)
							{
								enemy->Die();
								//分数更新
								UserManager* userMgr = UserManager::getInstance();
								userMgr->SetScore(userMgr->GetScore() + enemy->GetScore());
								enemy->SetScore(0);
								_scoreText->SetText("SCORE:" + to_string(userMgr->GetScore()));

								if (enemy->GetName().substr(0, 4).compare("boss") == 0)
								{
									if (userMgr->GetStage() < userMgr->GetStageMax())
									{
										userMgr->SetStage(userMgr->GetStage() + 1);
										if (_black == 0)
										{
											_black = Sprite::Create("Res/Login/black.png");
											_black->SetScale(500);
											Add(_black);
											ClearUpdateFunc();
											AddUpdateFunc(UpdateFunc::Create(CALLBACK_PARAMETER_1(MainScene::Fade, this)));
											AudioManager::getInstance()->stopBGM();
											AudioManager::getInstance()->playSoundEffect("Sound/se/clear.mp3");
											return;
										}
									}
									else
									{

									}
								}
							}
							else
							{
								Effect* boom = Effect::Create("fire1");
								boom->SetTextureBlend(true);
								boom->SetPosition(bullet->GetPositionX(), bullet->GetPositionY(), bullet->GetPositionZ());
								boom->SetOrder(LAYER_ENEMY_BOOM);
								Add(boom);
								AudioManager::getInstance()->playSoundEffect("Sound/se/beiji.ogg");
							}
						}
					}
				}
			}
			else if (Tools::CheckHit_UnInclude(list.at(i),
				viewPos.x - viewRect.right / 2.0f - 300,
				viewPos.y - viewRect.bottom / 2.0f - 300,
				viewPos.x + viewRect.right / 2.0f + 300,
				viewPos.y + viewRect.bottom / 2.0f + 300))
//.........这里部分代码省略.........
开发者ID:Jenovez,项目名称:Frame2D-old,代码行数:101,代码来源:MainScene.cpp


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