本文整理汇总了C++中gd::Project::CreateBehavior方法的典型用法代码示例。如果您正苦于以下问题:C++ Project::CreateBehavior方法的具体用法?C++ Project::CreateBehavior怎么用?C++ Project::CreateBehavior使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gd::Project
的用法示例。
在下文中一共展示了Project::CreateBehavior方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UnserializeFrom
void Object::UnserializeFrom(gd::Project & project, const SerializerElement & element)
{
//Name and type are already loaded.
objectVariables.UnserializeFrom(element.GetChild("variables", 0, "Variables"));
//Compatibility with GD <= 3.3
if (element.HasChild("Automatism"))
{
for (std::size_t i = 0; i < element.GetChildrenCount("Automatism"); ++i)
{
SerializerElement & behaviorElement = element.GetChild("Automatism", i);
gd::String autoType = behaviorElement.GetStringAttribute("type", "", "Type")
.FindAndReplace("Automatism", "Behavior");
gd::String autoName = behaviorElement.GetStringAttribute("name", "", "Name");
Behavior* behavior = project.CreateBehavior(autoType);
if ( behavior != NULL )
{
behavior->SetName(autoName);
behavior->UnserializeFrom(behaviorElement);
behaviors[behavior->GetName()] = behavior;
}
else
std::cout << "WARNING: Unknown behavior " << autoType << std::endl;
}
}
//End of compatibility code
else
{
SerializerElement & behaviorsElement = element.GetChild("behaviors", 0, "automatisms");
behaviorsElement.ConsiderAsArrayOf("behavior", "automatism");
for (std::size_t i = 0; i < behaviorsElement.GetChildrenCount(); ++i)
{
SerializerElement & behaviorElement = behaviorsElement.GetChild(i);
gd::String autoType = behaviorElement.GetStringAttribute("type")
.FindAndReplace("Automatism", "Behavior"); //Compatibility with GD <= 4
gd::String autoName = behaviorElement.GetStringAttribute("name");
Behavior* behavior = project.CreateBehavior(autoType);
if ( behavior != NULL )
{
behavior->SetName(autoName);
behavior->UnserializeFrom(behaviorElement);
behaviors[behavior->GetName()] = behavior;
}
else
std::cout << "WARNING: Unknown behavior " << autoType << std::endl;
}
}
DoUnserializeFrom(project, element);
}