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


C++ SoundManager::play方法代码示例

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


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

示例1: OnSmartFoxExtensionResponse

//! When something from a server extension is received this function is called. Could be position updating  of gameobject, a private message or just a notification. The ["cmd"] parameter of the event that is received  reveals which extension that was spitting out the info. Based on extension this function will do different things.
void NetworkManager::OnSmartFoxExtensionResponse(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent) {
	// get pointer to main frame.
	NetworkManager* ptrMainFrame = (NetworkManager*)ptrContext;

	// Check that we're still alive and running
	if (ptrMainFrame == NULL) {
		return;
	}

	// Get the cmd parameter of the event
	boost::shared_ptr<map<string, boost::shared_ptr<void>>> ptrEventParams = ptrEvent->Params();
	boost::shared_ptr<void> ptrEventParamValueCmd = (*ptrEventParams)["cmd"];
	boost::shared_ptr<string> ptrNotifiedCmd = ((boost::static_pointer_cast<string>)(ptrEventParamValueCmd));


	// check the type of the command
	if (*ptrNotifiedCmd == "PilotEvent") {
		boost::shared_ptr<void> ptrEventParamValueParams = (*ptrEventParams)["params"];
		boost::shared_ptr<ISFSObject> ptrNotifiedISFSObject = ((boost::static_pointer_cast<ISFSObject>)(ptrEventParamValueParams));

		pInputRotX = *(ptrNotifiedISFSObject->GetDouble("sgctRotY"));
		pInputRotZ = *(ptrNotifiedISFSObject->GetDouble("sgctRotX"));

		bool pInputForward = *(ptrNotifiedISFSObject->GetBool("sgctForward"));
		//bool pInputBackward = *(ptrNotifiedISFSObject->GetBool("sgctBackward"));

		accRotX += pInputRotX * accRotVal;
		accRotZ += pInputRotZ * accRotVal;

		if (pInputForward) {
			if (enginePowerup.getVal() <= 0.0 && navigationSpeed < accThrustMax * eInputEngine)
				navigationSpeed += accThrustVal * eInputEngine;
			else if (navigationSpeed < accThrustMax * eInputEngine * 2.0)
				navigationSpeed += accThrustVal * eInputEngine * 2.0;
		}
		//if (pInputBackward && navigationSpeed > -0.1) {
		//	navigationSpeed -= accThrustVal * eInputEngine;
		//}
	}

	if (*ptrNotifiedCmd == "GunnerEvent") {
		boost::shared_ptr<void> ptrEventParamValueParams = (*ptrEventParams)["params"];
		boost::shared_ptr<ISFSObject> ptrNotifiedISFSObject = ((boost::static_pointer_cast<ISFSObject>)(ptrEventParamValueParams));

		gInputRotX = *(ptrNotifiedISFSObject->GetDouble("sgctRotX")) * 3.0;
		gInputRotY = *(ptrNotifiedISFSObject->GetDouble("sgctRotY")) * 3.0;
		bool fire = *(ptrNotifiedISFSObject->GetBool("sgctFire"));

		

		if (fire && fireTimer <= 0.0) {
			//if (gEngine->isMaster())
			soundManager.play("laser", osg::Vec3f(0.0f, 0.0f, 0.0f));
			fireSync.setVal(true);
			fireTimer = fireRate / eInputTurret;
		}
	}
	if (*ptrNotifiedCmd == "EngineerEvent") {
		boost::shared_ptr<void> ptrEventParamValueParams = (*ptrEventParams)["params"];
		boost::shared_ptr<ISFSObject> ptrNotifiedISFSObject = ((boost::static_pointer_cast<ISFSObject>)(ptrEventParamValueParams));

		eInputEngine = ((float)(*(ptrNotifiedISFSObject->GetFloat("sgctEngine"))) * 3 + 0.5);	//	0.5 - 3.5
		eInputShield = 1.0 - 0.75 * ((float)(*(ptrNotifiedISFSObject->GetFloat("sgctShield"))));//	1.0 - 0.25	(percent of damage taken)
		eInputTurret = ((float)(*(ptrNotifiedISFSObject->GetFloat("sgctTurret"))) + 0.5);		//	0.5 - 1.5

	}
	if (*ptrNotifiedCmd == "BenchMarking") {

		boost::shared_ptr<void> ptrEventParamValueParams = (*ptrEventParams)["params"];
		boost::shared_ptr<ISFSObject> ptrNotifiedISFSObject = ((boost::static_pointer_cast<ISFSObject>)(ptrEventParamValueParams));

		double item = *(ptrNotifiedISFSObject->GetDouble("1"));
		double item2 = *(ptrNotifiedISFSObject->GetDouble("2"));
		double item3 = *(ptrNotifiedISFSObject->GetDouble("3"));
		double item4 = *(ptrNotifiedISFSObject->GetDouble("4"));

		end = omp_get_wtime();
		std::cout << "Reply from server, " << static_cast<int>((end - start) * 1000) << "ms." << endl;

		start = omp_get_wtime();
		// send new item 
		if (itemsSent++ < 35 && benchmarkingStarted) {
			boost::shared_ptr<ISFSObject> parameters(new SFSObject());

			parameters->PutDouble("1", 0.923);
			parameters->PutDouble("2", 0.953);
			parameters->PutDouble("3", 0.343);
			parameters->PutDouble("4", 0.523);

			// find our room to send to.
			boost::shared_ptr<Room> lastJoined = ptrMainFrame->m_ptrSmartFox->LastJoinedRoom();

			// Perform extensionrequest
			boost::shared_ptr<IRequest> extRequest(new ExtensionRequest("BenchMarking", parameters, lastJoined));
			ptrMainFrame->m_ptrSmartFox->Send(extRequest);
		}
		else {
			benchmarkingStarted = false;
			itemsSent = 0;
//.........这里部分代码省略.........
开发者ID:flair2005,项目名称:GameOfDomes_domeClient,代码行数:101,代码来源:main.cpp


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