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


C++ CGameObject::Deserialize方法代码示例

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


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

示例1: InstantiatePrototype

	CGameObject* CFactory::InstantiatePrototype(const string &AProtoName, const string &AName /*= ""*/)
	{
		CXMLNode *xml = GetPrototypeXML(AProtoName);
		if (!xml)
		{
			Log("ERROR", "Can't create prototype instance: no such prototype: '%s'", AProtoName.c_str());
			return NULL;
		}

		CGameObject *result = New<CGameObject>(AName);

		if (AName.empty())
			result->SetName(AProtoName + itos(result->GetID()));

		result->Prototype = true;
		result->Deserialize(xml);

		SetRecursionLimit(AProtoName, from_string<int>(xml->SafeGetAttribute("RecursionLimit", "-1")));

		TraversePrototypeNode(xml, result, result);

		result->FinalizeCreation();

		Log("INFO", "Prototype INSTANTIATED: '%s', instance name: '%s'", AProtoName.c_str(), result->GetName().c_str());

		return result;
	}
开发者ID:rotanov,项目名称:deku2d-engine,代码行数:27,代码来源:2de_Factory.cpp

示例2: TraversePrototypeNode

	void CFactory::TraversePrototypeNode(CXMLNode *ANode, CGameObject *AObject, CGameObject *CurrentProto)
	{
		CGameObject *child;
		string NodeName;
		string ChildName;
		string LocalChildName;

		for (CXMLChildrenList::Iterator it = ANode->Children.Begin(); it != ANode->Children.End(); ++it)
		{
			if ((*it)->GetType() != CXMLNode::XML_NODE_TYPE_NORMAL)
				continue;

			NodeName = (*it)->GetName(); 

			int recursionsLeft = GetRecursionsLeft(NodeName);
			if (recursionsLeft < 1)
			{
				if (recursionsLeft == -1)
					Log("ERROR", "Unlimited recursive reference of prototype '%s'", NodeName.c_str());

				continue;
			}

			IncreaseUsedCount(NodeName);

			ChildName = (*it)->SafeGetAttribute("Name");
			LocalChildName = (*it)->SafeGetAttribute("LocalName");

			child = CreateGameObject(NodeName, ChildName, false);
			if (!child)
			{
				Log("ERROR", "Can't create object of class '%s' from prototype", NodeName.c_str());
				continue;
			}

			CurrentProto->AddLocalName(LocalChildName, child);

			child->Deserialize(*it);
			AObject->Attach(child);

			if (!child->IsPrototype())
				child->FinalizeCreation();

			TraversePrototypeNode(*it, child, CurrentProto);

			DecreaseUsedCount(NodeName);
		}
	}
开发者ID:rotanov,项目名称:deku2d-engine,代码行数:48,代码来源:2de_Factory.cpp


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