本文整理汇总了C++中Entity::GetChild方法的典型用法代码示例。如果您正苦于以下问题:C++ Entity::GetChild方法的具体用法?C++ Entity::GetChild怎么用?C++ Entity::GetChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entity
的用法示例。
在下文中一共展示了Entity::GetChild方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SafeRetain
CommandInternalRemoveSceneNode::CommandInternalRemoveSceneNode(Entity* node, bool removeSimilar)
: Command(Command::COMMAND_UNDO_REDO, CommandList::ID_COMMAND_INTERNAL_REMOVE_SCENE_NODE)
{
commandName = "Remove Object";
if (removeSimilar)
commandName += "s";
if (!node || !node->GetParent())
return;
if (removeSimilar)
{
String referenceToOwner;
Entity* nodeParent = node->GetParent();
KeyedArchive *customProperties = node->GetCustomProperties();
if(customProperties && customProperties->IsKeyExists(ResourceEditor::EDITOR_REFERENCE_TO_OWNER))
{
referenceToOwner = customProperties->GetString(ResourceEditor::EDITOR_REFERENCE_TO_OWNER);
}
nodesForDeletion.reserve(nodeParent->GetChildrenCount());
for (int32 i = 0; i < nodeParent->GetChildrenCount(); ++i)
{
Entity* child = nodeParent->GetChild(i);
customProperties = child->GetCustomProperties();
if (customProperties && customProperties->IsKeyExists(ResourceEditor::EDITOR_REFERENCE_TO_OWNER))
{
if (customProperties->GetString(ResourceEditor::EDITOR_REFERENCE_TO_OWNER) == referenceToOwner)
{
RemoveNodeRec removeNodeRec;
removeNodeRec.node = SafeRetain(child);
removeNodeRec.nodeParent = nodeParent;
int32 i = GetNodeIndex(removeNodeRec);
if (i >= 0 && i < nodeParent->GetChildrenCount() - 1)
removeNodeRec.insertBeforeNode = nodeParent->GetChild(i + 1);
nodesForDeletion.push_back(removeNodeRec);
}
}
}
}
else
{
RemoveNodeRec removeNodeRec;
removeNodeRec.node = SafeRetain(node);
removeNodeRec.nodeParent = node->GetParent();
int32 i = GetNodeIndex(removeNodeRec);
if (i >= 0 && i < removeNodeRec.nodeParent->GetChildrenCount() - 1)
removeNodeRec.insertBeforeNode = removeNodeRec.nodeParent->GetChild(i + 1);
nodesForDeletion.push_back(removeNodeRec);
}
selectedNode = node;
}
示例2: SaveFile
void SceneSaver::SaveFile(const String &fileName, Set<String> &errorLog)
{
Logger::Info("[SceneSaver::SaveFile] %s", fileName.c_str());
FilePath filePath = sceneUtils.dataSourceFolder + fileName;
//Load scene with *.sc2
Scene *scene = new Scene();
Entity *rootNode = scene->GetRootNode(filePath);
if(rootNode)
{
int32 count = rootNode->GetChildrenCount();
Vector<Entity*> tempV;
tempV.reserve((count));
for(int32 i = 0; i < count; ++i)
{
tempV.push_back(rootNode->GetChild(i));
}
for(int32 i = 0; i < count; ++i)
{
scene->AddNode(tempV[i]);
}
SaveScene(scene, filePath, errorLog);
}
else
{
errorLog.insert(Format("[SceneSaver::SaveFile] Can't open file %s", fileName.c_str()));
}
SafeRelease(scene);
}
示例3: ReloadParticleSprites
void SpritePackerHelper::ReloadParticleSprites(SceneData* sceneData)
{
List<Entity*> particleEffects;
sceneData->GetAllParticleEffects(particleEffects);
for (auto it = particleEffects.begin(); it != particleEffects.end(); ++it)
{
Entity* curNode = (*it);
ParticleEffectComponent * effectComponent = cast_if_equal<ParticleEffectComponent*>(curNode->GetComponent(Component::PARTICLE_EFFECT_COMPONENT));
if (!effectComponent)
{
continue;
}
effectComponent->Stop();
// All the children of this Scene Node must have Emitter components.
int32 emittersCount = curNode->GetChildrenCount();
for (int32 i = 0; i < emittersCount; i ++)
{
Entity* childNode = curNode->GetChild(i);
ParticleEmitter * emitter = GetEmitter(childNode);
if (!emitter)
{
continue;
}
emitter->ReloadLayerSprites();
}
effectComponent->Start();
}
}
示例4: ResaveFile
void SceneSaver::ResaveFile(const String &fileName, Set<String> &errorLog)
{
DVASSERT(0); //TODO: check save
Logger::Info("[SceneSaver::ResaveFile] %s", fileName.c_str());
FilePath sc2Filename = sceneUtils.dataSourceFolder + fileName;
//Load scene with *.sc2
Scene *scene = new Scene();
Entity *rootNode = scene->GetRootNode(sc2Filename);
if(rootNode)
{
int32 count = rootNode->GetChildrenCount();
Vector<Entity*> tempV;
tempV.reserve((count));
for(int32 i = 0; i < count; ++i)
{
tempV.push_back(rootNode->GetChild(i));
}
for(int32 i = 0; i < count; ++i)
{
scene->AddNode(tempV[i]);
}
scene->Update(0.f);
SceneFileV2 * outFile = new SceneFileV2();
outFile->EnableDebugLog(false);
outFile->SaveScene(sc2Filename, scene);
SafeRelease(outFile);
}
else
{
errorLog.insert(Format("[SceneSaver::ResaveFile] Can't open file %s", fileName.c_str()));
}
SafeRelease(scene);
}
示例5: Scene
DAVA::Scene * DAEConvertWithSettingsAction::CreateSceneFromSc2(const DAVA::FilePath &scenePathname)
{
Scene * scene = new Scene();
Entity * rootNode = scene->GetRootNode(scenePathname);
if(rootNode)
{
rootNode = rootNode->Clone();
Vector<Entity*> tmpEntities;
uint32 entitiesCount = (uint32)rootNode->GetChildrenCount();
// optimize scene
SceneFileV2 *sceneFile = new SceneFileV2();
sceneFile->OptimizeScene(rootNode);
sceneFile->Release();
// remember all child pointers, but don't add them to scene in this cycle
// because when entity is adding it is automatically removing from its old hierarchy
tmpEntities.reserve(entitiesCount);
for (uint32 i = 0; i < entitiesCount; ++i)
{
tmpEntities.push_back(rootNode->GetChild(i));
}
// now we can safely add entities into our hierarchy
for (uint32 i = 0; i < (uint32) tmpEntities.size(); ++i)
{
scene->AddNode(tmpEntities[i]);
}
rootNode->Release();
Set<String> errorsLog;
SceneValidator::Instance()->ValidateScene(scene, scenePathname, errorsLog);
}
return scene;
}