本文整理汇总了C++中XMLFile::GetRoot方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLFile::GetRoot方法的具体用法?C++ XMLFile::GetRoot怎么用?C++ XMLFile::GetRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLFile
的用法示例。
在下文中一共展示了XMLFile::GetRoot方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HANDLER
void RogueSkill4::Start()
{
skillSprite_ = (Sprite*)(main_->mySceneNode_->GetComponent<HUD>()->
hud_->GetChild("skill4", false)->GetChild(0)->GetChild(0));
SubscribeToEvent(E_HUDBUTT, HANDLER(RogueSkill4, HandleHudButt));
SetUpdateEventMask(USE_UPDATE);
XMLFile* xmlFile = main_->cache_->GetResource<XMLFile>("Objects/terriesDagger1.xml");
arrow_ = node_->GetScene()->InstantiateXML(xmlFile->GetRoot(),
Vector3::ZERO, Quaternion::IDENTITY, LOCAL);
arrow_->SetEnabled(false);
}
示例2: HANDLER
void WizardSkill0::Start()
{
skillSprite_ = (Sprite*)(main_->mySceneNode_->GetComponent<HUD>()->
hud_->GetChild("skill0", false)->GetChild(0)->GetChild(0));
SubscribeToEvent(E_HUDBUTT, HANDLER(WizardSkill0, HandleHudButt));
SetUpdateEventMask(USE_UPDATE);
XMLFile* xmlFile = main_->cache_->GetResource<XMLFile>("Objects/terriesMeteor.xml");
meteor_ = node_->GetScene()->InstantiateXML(xmlFile->GetRoot(),
Vector3::ZERO, Quaternion::IDENTITY, LOCAL);
meteor_->SetEnabled(false);
SubscribeToEvent(E_NODEREMOVED, HANDLER(WizardSkill0, HandleNodeRemoved));
}
示例3: HANDLER
void WizardSkill4::Start()
{
skillSprite_ = (Sprite*)(main_->mySceneNode_->GetComponent<HUD>()->
hud_->GetChild("skill4", false)->GetChild(0)->GetChild(0));
SubscribeToEvent(E_HUDBUTT, HANDLER(WizardSkill4, HandleHudButt));
SetUpdateEventMask(USE_UPDATE);
XMLFile* xmlFile = main_->cache_->GetResource<XMLFile>("Objects/terriesOrb.xml");
orb_ = node_->GetScene()->InstantiateXML(xmlFile->GetRoot(),
Vector3::ZERO, Quaternion::IDENTITY, LOCAL);
orb_->SetPosition(node_->GetScene()->GetChild("tent")->GetPosition() + (Vector3::UP * 2.0f));
SubscribeToEvent(orb_, E_NODECOLLISIONSTART, HANDLER(WizardSkill4, HandleNodeCollisionStart));
//orb_->SetEnabled(false);
}
示例4: QueryMasterServer
void GameMenu::QueryMasterServer()
{
if (!masterServerConnected_)
{
XMLFile* xmlFile = main_->cache_->GetResource<XMLFile>("Objects/serverInfo.xml");
Node* serverInfo = main_->scene_->InstantiateXML(xmlFile->GetRoot(), Vector3::ZERO, Quaternion(), LOCAL);
masterServerIP_ = serverInfo->GetVar("masterServerIP").GetString();
main_->scene_->RemoveChild(serverInfo);
if (masterServerIP_ == "127.0.0.1")
{
return;
}
masterServerConnected_ = network_->Connect(masterServerIP_, 9001, 0);
}
}
示例5: LoadParameters
void Sound::LoadParameters()
{
ResourceCache* cache = GetSubsystem<ResourceCache>();
String xmlName = ReplaceExtension(GetName(), ".xml");
if (!cache->Exists(xmlName))
return;
XMLFile* file = cache->GetResource<XMLFile>(xmlName);
if (!file)
return;
XMLElement rootElem = file->GetRoot();
XMLElement paramElem = rootElem.GetChild();
while (paramElem)
{
String name = paramElem.GetName();
if (name == "format" && !compressed_)
{
if (paramElem.HasAttribute("frequency"))
frequency_ = paramElem.GetInt("frequency");
if (paramElem.HasAttribute("sixteenbit"))
sixteenBit_ = paramElem.GetBool("sixteenbit");
if (paramElem.HasAttribute("16bit"))
sixteenBit_ = paramElem.GetBool("16bit");
if (paramElem.HasAttribute("stereo"))
stereo_ = paramElem.GetBool("stereo");
}
if (name == "loop")
{
if (paramElem.HasAttribute("enable"))
SetLooped(paramElem.GetBool("enable"));
if (paramElem.HasAttribute("start") && paramElem.HasAttribute("end"))
SetLoop(paramElem.GetInt("start"), paramElem.GetInt("end"));
}
paramElem = paramElem.GetNext();
}
}
示例6: MoveCamera
void SceneView3D::HandleUpdate(StringHash eventType, VariantMap& eventData)
{
// Timestep parameter is same no matter what event is being listened to
float timeStep = eventData[Update::P_TIMESTEP].GetFloat();
if (MouseInView())
MoveCamera(timeStep);
QueueUpdate();
if (preloadResourceScene_.NotNull())
{
if (preloadResourceScene_->GetAsyncProgress() == 1.0f)
{
ResourceCache* cache = GetSubsystem<ResourceCache>();
XMLFile* xml = cache->GetResource<XMLFile>(dragAssetGUID_);
if (dragNode_.NotNull())
{
dragNode_->LoadXML(xml->GetRoot());
UpdateDragNode(0, 0);
AnimationController* controller = dragNode_->GetComponent<AnimationController>();
if (controller)
{
controller->PlayExclusive("Idle", 0, true);
dragNode_->GetScene()->SetUpdateEnabled(true);
}
}
preloadResourceScene_ = 0;
dragAssetGUID_ = "";
}
}
}
示例7: Load
bool Animation::Load(Deserializer& source)
{
PROFILE(LoadAnimation);
unsigned memoryUse = sizeof(Animation);
// Check ID
if (source.ReadFileID() != "UANI")
{
LOGERROR(source.GetName() + " is not a valid animation file");
return false;
}
// Read name and length
animationName_ = source.ReadString();
animationNameHash_ = animationName_;
length_ = source.ReadFloat();
tracks_.Clear();
unsigned tracks = source.ReadUInt();
tracks_.Resize(tracks);
memoryUse += tracks * sizeof(AnimationTrack);
// Read tracks
for (unsigned i = 0; i < tracks; ++i)
{
AnimationTrack& newTrack = tracks_[i];
newTrack.name_ = source.ReadString();
newTrack.nameHash_ = newTrack.name_;
newTrack.channelMask_ = source.ReadUByte();
unsigned keyFrames = source.ReadUInt();
newTrack.keyFrames_.Resize(keyFrames);
memoryUse += keyFrames * sizeof(AnimationKeyFrame);
// Read keyframes of the track
for (unsigned j = 0; j < keyFrames; ++j)
{
AnimationKeyFrame& newKeyFrame = newTrack.keyFrames_[j];
newKeyFrame.time_ = source.ReadFloat();
if (newTrack.channelMask_ & CHANNEL_POSITION)
newKeyFrame.position_ = source.ReadVector3();
if (newTrack.channelMask_ & CHANNEL_ROTATION)
newKeyFrame.rotation_ = source.ReadQuaternion();
if (newTrack.channelMask_ & CHANNEL_SCALE)
newKeyFrame.scale_ = source.ReadVector3();
}
}
// Optionally read triggers from an XML file
ResourceCache* cache = GetSubsystem<ResourceCache>();
String xmlName = ReplaceExtension(GetName(), ".xml");
if (cache->Exists(xmlName))
{
XMLFile* file = cache->GetResource<XMLFile>(xmlName);
if (file)
{
XMLElement rootElem = file->GetRoot();
XMLElement triggerElem = rootElem.GetChild("trigger");
while (triggerElem)
{
if (triggerElem.HasAttribute("normalizedtime"))
AddTrigger(triggerElem.GetFloat("normalizedtime"), true, triggerElem.GetVariant());
else if (triggerElem.HasAttribute("time"))
AddTrigger(triggerElem.GetFloat("time"), false, triggerElem.GetVariant());
triggerElem = triggerElem.GetNext("trigger");
}
memoryUse += triggers_.Size() * sizeof(AnimationTriggerPoint);
}
}
SetMemoryUse(memoryUse);
return true;
}
示例8: LoadSprite
Node* TerrySpawner::LoadSprite(String name)
{
//Vector3 startPos = terrySpawns_->GetChild(Random(0,terrySpawns_->GetNumChildren()))->GetPosition();
Vector3 startPos = spawnPoint_;
XMLFile* xmlFile = main_->cache_->GetResource<XMLFile>("Objects/terriesNode.xml");
Node* spriteNode = scene_->InstantiateXML(xmlFile->GetRoot(),
startPos, Quaternion::IDENTITY, LOCAL);
spriteNode->RemoveChild(spriteNode->GetChild("camera"));
spriteNode->SetName(name);
spriteNode->AddComponent(new Gravity(context_, main_), 0, LOCAL);
spriteNode->AddComponent(new Speed(context_, main_), 0, LOCAL);
//spriteNode->AddComponent(new RotateTo(context_, main_), 0, LOCAL);
spriteNode->AddComponent(new MoveByTouch(context_, main_), 0, LOCAL);
spriteNode->AddComponent(new Health(context_, main_), 0, LOCAL);
spriteNode->GetComponent<MoveByTouch>()->UnsubscribeFromEvent(E_HUDBUTT);
StaticSprite2D* sprite = spriteNode->CreateComponent<StaticSprite2D>();
sprite->SetCustomMaterial(SharedPtr<Material>(main_->cache_->GetResource<Material>("Materials/" + name + "Mat.xml")));
AnimatedSpriteSheet* animatedSpriteSheet = new AnimatedSpriteSheet();
animatedSpriteSheet->sheet_ = main_->cache_->GetResource<SpriteSheet2D>("Urho2D/" + name + "/" + name + "Sheet.xml");
animatedSpriteSheet->staticSprite_ = sprite;
animatedSpriteSheet->playing_ = false;
animatedSpriteSheet->spriteID_ = spriteIDCount_;
animatedSpriteSheet->noed_ = spriteNode;
animatedSpriteSheet->flipX_ = false;
sprites_.Push(animatedSpriteSheet);
spriteIDCount_++;
Vector<String> files;
files.Push("attackF.xml");
files.Push("attackM.xml");
files.Push("dieF.xml");
files.Push("dieM.xml");
files.Push("gestureF.xml");
files.Push("gestureM.xml");
files.Push("idleF.xml");
files.Push("idleM.xml");
files.Push("runF.xml");
files.Push("runM.xml");
/*main_->filesystem_->ScanDir(files,
main_->filesystem_->GetProgramDir() + "Data/Urho2D/" + name + "/animations/",
"*.xml", SCAN_FILES, false);*/
for (int x = 0; x < files.Size(); x++)
{
XMLElement ani = main_->cache_->GetResource<XMLFile>("Urho2D/" + name + "/animations/" + files[x])->GetRoot();
SpriteSheetAnimation* spriteSheetAni = new SpriteSheetAnimation();
animatedSpriteSheet->animations_.Push(spriteSheetAni);
spriteSheetAni->name_ = ani.GetChild("Name").GetAttribute("name");
spriteSheetAni->loop_ = ani.GetChild("Loop").GetBool("loop");
int frameCount = ani.GetChild("FrameCount").GetInt("frameCount");
for (int x = 0; x < frameCount; x++)
{
SpriteSheetAnimationFrame* frame = new SpriteSheetAnimationFrame();
spriteSheetAni->frames_.Push(frame);
String child = "Frame" + String(x);
frame->duration_ = ani.GetChild(child).GetFloat("duration");
frame->sprite_ = ani.GetChild(child).GetAttribute("sprite");
}
}
bool sex = Random(0,2);
animatedSpriteSheet->noed_->SetVar("sex",sex);
VariantMap vm;
vm[AnimateSpriteSheet::P_NODE] = node_;
vm[AnimateSpriteSheet::P_SPRITEID] = animatedSpriteSheet->spriteID_;
if (sex)
{
vm[AnimateSpriteSheet::P_ANIMATION] = "idleF";
}
else
{
vm[AnimateSpriteSheet::P_ANIMATION] = "idleM";
}
vm[AnimateSpriteSheet::P_FLIPX] = 0;
SendEvent(E_ANIMATESPRITESHEET, vm);
animatedSpriteSheet->noed_->SetVar("collisionCount",0);
animatedSpriteSheet->noed_->SetVar("attack",1);
animatedSpriteSheet->noed_->SetVar("attackInterval",1.0f);
animatedSpriteSheet->noed_->SetVar("attackElapsedTime",0.0f);
//.........这里部分代码省略.........
示例9: LoadConfiguration
void GameEconomicGameClient::LoadConfiguration(Configuration &configuration)
{
/// Grab resources
FileSystem * fileSystem = GetSubsystem<FileSystem>();
/// Set all defaults
bool success=false;
configuration.GameModeForceTablet=false;
configuration.VideoBloomParam1=0.9f;
configuration.VideoBloomParam2=0.6f;
/// Create String
String configFileName;
/// Set directory and path for network file
configFileName.Append(fileSystem->GetProgramDir().CString());
configFileName.Append("");
configFileName.Append("Configuration.xml");
/// If file does not exist exit function with null structure
if (!fileSystem->FileExists(configFileName))
{
cout << "Configuration file not found.. Using defaults.. " << endl;
return;
}
/// Flag file for loading and load
File loadFile(context_, configFileName, FILE_READ);
XMLFile * configurationXML = new XMLFile(context_);
configurationXML -> Load(loadFile);
XMLElement configElem = configurationXML->GetRoot();
/// If no configuration is set or no root
if (configElem.IsNull())
{
cout << "Configuration file not found.. Using defaults.. " << endl;
return;
}
/// Basic Config
XMLElement GameModeConfigurationElem = configElem.GetChild("GameModeConfiguration");
/// If no network server element return false;
if (!GameModeConfigurationElem.IsNull())
{
if (GameModeConfigurationElem.HasAttribute("GameModeForceTablet")) configuration.GameModeForceTablet = GameModeConfigurationElem.GetBool("GameModeForceTablet");
}
/// Basic Config
XMLElement VideoConfigurationElem = configElem.GetChild("VideoConfiguration");
/// If no network server element return false;
if (!VideoConfigurationElem.IsNull())
{
if (VideoConfigurationElem.HasAttribute("BloomParam1")) configuration.VideoBloomParam1= VideoConfigurationElem.GetFloat("BloomParam1");
if (VideoConfigurationElem.HasAttribute("BloomParam2")) configuration.VideoBloomParam2= VideoConfigurationElem.GetFloat("BloomParam2");
}
return;
}
示例10: LoadCommunicationLogs
/// Load Communication Logs
bool GameEconomicGameClient::LoadCommunicationLogs(LogFormatType LogType, Vector<CommunicationLog> * TargetLogs)
{
/// Grab resources
FileSystem * fileSystem = GetSubsystem<FileSystem>();
bool success=false;
/// Create String
String configFileName;
/// Set directory and path for network file
configFileName.Append(fileSystem->GetProgramDir().CString());
configFileName.Append("CommunicationLogs/DefaultLogs.xml");
/// If file does not exist exit function with null structure
if (!fileSystem->FileExists(configFileName))
{
cout << "No file found communication log" << endl;
return false;
}
/// Flag file for loading and load
File loadFile(context_, configFileName, FILE_READ);
XMLFile * communicationXML = new XMLFile(context_);
communicationXML -> Load(loadFile);
XMLElement communicationRootElement = communicationXML->GetRoot();
/// If no configuration is set or no root
if (communicationRootElement.IsNull())
{
return false;
}
/// Setupload data
XMLElement TempLogElement;
String FormatText;
/// Log log format Personal
if(LogType == LogFormat_Personal)
{
FormatText.Append(String("PersonalLog"));
TempLogElement = communicationRootElement.GetChild(FormatText);
}
else
{
return false;
}
/// If no network server element return false;
while(!TempLogElement.IsNull())
{
/// Create a temporary log
CommunicationLog TempLog;
if (TempLogElement.HasAttribute("LogCreation")) TempLog.Creation= TempLogElement.GetInt("LogCreation");
if (TempLogElement.HasAttribute("LogTitle")) TempLog.Title = TempLogElement.GetAttribute("LogTitle");
if (TempLogElement.HasAttribute("LogText")) TempLog.Text = TempLogElement.GetAttribute("LogText");
TargetLogs->Push(TempLog);
cout << "Adding" << TempLog.Title.CString()<<endl;
/// Get next
TempLogElement=communicationRootElement.GetNext(FormatText);
}
return success;
}