本文整理汇总了C++中UIElement::GetName方法的典型用法代码示例。如果您正苦于以下问题:C++ UIElement::GetName方法的具体用法?C++ UIElement::GetName怎么用?C++ UIElement::GetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIElement
的用法示例。
在下文中一共展示了UIElement::GetName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleControlClicked
void HelloGUI::HandleControlClicked(StringHash eventType, VariantMap& eventData)
{
// Get the Text control acting as the Window's title
Text* windowTitle = static_cast<Text*>(window_->GetChild("WindowTitle", true));
// Get control that was clicked
UIElement* clicked = static_cast<UIElement*>(eventData[UIMouseClick::P_ELEMENT].GetPtr());
String name = "...?";
if (clicked)
{
// Get the name of the control that was clicked
name = clicked->GetName();
}
// Update the Window's title text
windowTitle->SetText("Hello " + name + "!");
}
示例2: HandleControlClicked
void GameMain::HandleControlClicked(StringHash eventType, VariantMap& eventData)
{
// Get control that was clicked
UIElement* clicked = static_cast<UIElement*>(eventData[UIMouseClick::P_ELEMENT].GetPtr());
String name = "...?";
if (clicked)
{
// Get the name of the control that was clicked
name = clicked->GetName();
if (name == "New Game")
{
}
else if (name == "Exit")
{
engine_->Exit();
}
}
}
示例3: HANDLER
void RogueSkill4::HandleHudButt(StringHash eventType, VariantMap& eventData)
{
UIElement* ele = static_cast<UIElement*>(eventData[HudButt::P_BUTT].GetPtr());
String name = ele->GetName();
if (name == "rogue")
{
skillSprite_->SetTexture(main_->cache_->
GetResource<Texture2D>("Textures/terriesHud/icons/rogue/W_Throw05.png"));
skillSprite_->SetOpacity(1.0f);
}
if (name == "skill4")
{
if (node_->HasComponent<Dead>())
{
return;
}
if (main_->mySceneNode_->GetComponent<SpriteSheetPlayer>()->focusedSprite_ == "rogue")
{
if (enabled_)
{
//node_->RemoveComponent<Stunned>();
enabled_ = false;
return;
}
if (!touchSubscribed_)
{
touchSubscribed_ = true;
VariantMap vm;
SendEvent(E_TOUCHSUBSCRIBE, vm);
}
SubscribeToEvent(E_TOUCHEND, HANDLER(RogueSkill4, HandleTouchEnd));
}
}
}
示例4: HANDLER
void WizardSkill0::HandleHudButt(StringHash eventType, VariantMap& eventData)
{
UIElement* ele = static_cast<UIElement*>(eventData[HudButt::P_BUTT].GetPtr());
String name = ele->GetName();
if (name == "wizard")
{
skillSprite_->SetTexture(main_->cache_->
GetResource<Texture2D>("Textures/terriesHud/icons/wizard/S_Fire05.png"));
skillSprite_->SetOpacity(1.0f);
}
if (name == "skill0")
{
if (node_->HasComponent<Dead>())
{
return;
}
if (main_->mySceneNode_->GetComponent<SpriteSheetPlayer>()->focusedSprite_ == "wizard")
{
if (touchSubscribed_ || cooling_)
{
return;
}
if (!touchSubscribed_)
{
touchSubscribed_ = true;
VariantMap vm;
SendEvent(E_TOUCHSUBSCRIBE, vm);
}
SubscribeToEvent(E_TOUCHEND, HANDLER(WizardSkill0, HandleTouchEnd));
}
}
}
示例5: Health
void RangerSkill4::HandleHudButt(StringHash eventType, VariantMap& eventData)
{
UIElement* ele = static_cast<UIElement*>(eventData[HudButt::P_BUTT].GetPtr());
String name = ele->GetName();
if (name == "ranger")
{
skillSprite_->SetTexture(main_->cache_->
GetResource<Texture2D>("Textures/terriesHud/icons/ranger/I_SnailShell.png"));
skillSprite_->SetOpacity(1.0f);
}
if (name == "skill4")
{
if (node_->HasComponent<Dead>())
{
return;
}
if (main_->mySceneNode_->GetComponent<SpriteSheetPlayer>()->focusedSprite_ == "ranger")
{
Node* snail = snail_->Clone(LOCAL);
snail->AddComponent(new Health(context_, main_), 0, LOCAL);
snail->GetComponent<Health>()->killOn0_ = true;
snail->GetComponent<Health>()->health_ = 1000;
snail->SetEnabled(true);
snail->SetPosition(node_->GetPosition() + (Vector3::BACK * 0.75) + (Vector3::UP * 0.25f));
VariantMap vm;
vm[AnimateSceneNode::P_NODE] = node_;
if (node_->GetVar("sex").GetBool())
{
vm[AnimateSceneNode::P_ANIMATION] = "gestureF";
}
else
{
vm[AnimateSceneNode::P_ANIMATION] = "gestureM";
}
vm[AnimateSceneNode::P_LOOP] = false;
vm[AnimateSceneNode::P_LAYER] = 0;
SendEvent(E_ANIMATESCENENODE, vm);
Node* particleStartNode_ = node_->GetScene()->CreateChild(0,LOCAL);
/*ParticleEmitter* emitterStartFX_ = particleStartNode_->CreateComponent<ParticleEmitter>(LOCAL);
emitterStartFX_->SetEffect(main_->cache_->GetResource<ParticleEffect>("Particle/dustCloud.xml"));
emitterStartFX_->SetViewMask(1);*/
particleStartNode_->SetPosition(node_->GetPosition());
//emitterStartFX_->SetEmitting(true);
particleStartNode_->AddComponent(new TimedRemove(context_, main_, 2.0f), 0, LOCAL);
particleStartNode_->AddComponent(new SoundSource3D(context_), 0, LOCAL);
particleStartNode_->GetComponent<SoundSource3D>()->SetGain(0.1f);
particleStartNode_->GetComponent<SoundSource3D>()->Play(main_->cache_->GetResource<Sound>("Sounds/265385__b-lamerichs__sound-effects-01-03-2015-8-pops-2.ogg"));
}
}
}
示例6:
void WarriorSkill1::HandleHudButt(StringHash eventType, VariantMap& eventData)
{
UIElement* ele = static_cast<UIElement*>(eventData[HudButt::P_BUTT].GetPtr());
String name = ele->GetName();
if (name == "warrior")
{
skillSprite_->SetTexture(main_->cache_->
GetResource<Texture2D>("Textures/terriesHud/icons/warrior/S_Buff14.png"));
skillSprite_->SetOpacity(1.0f);
}
if (name == "skill1")
{
if (node_->HasComponent<Dead>())
{
return;
}
if (cooling_){return;}
if (main_->mySceneNode_->GetComponent<SpriteSheetPlayer>()->focusedSprite_ == "warrior")
{
node_->GetComponent<Armor>()->ModifyArmor(1, -1, false);
int attack = node_->GetVar("attack").GetInt();
node_->SetVar("attack", attack + 50);
float attackInterval = node_->GetVar("attackInterval").GetFloat();
node_->SetVar("attackInterval", attackInterval * 0.5f);
elapsedTime_ = 0.0f;
durationElapsedTime_ = 0.0f;
processing_ = true;
cooling_ = true;
VariantMap vm;
vm[AnimateSceneNode::P_NODE] = node_;
if (node_->GetVar("sex").GetBool())
{
vm[AnimateSceneNode::P_ANIMATION] = "gestureF";
}
else
{
vm[AnimateSceneNode::P_ANIMATION] = "gestureM";
}
vm[AnimateSceneNode::P_LOOP] = false;
vm[AnimateSceneNode::P_LAYER] = 0;
SendEvent(E_ANIMATESCENENODE, vm);
Node* particleStartNode_ = node_->GetScene()->CreateChild(0,LOCAL);
ParticleEmitter* emitterStartFX_ = particleStartNode_->CreateComponent<ParticleEmitter>(LOCAL);
emitterStartFX_->SetEffect(main_->cache_->GetResource<ParticleEffect>("Particle/terriesFury.xml"));
emitterStartFX_->SetViewMask(1);
emitterStartFX_->SetEmitting(true);
node_->AddChild(particleStartNode_);
particleStartNode_->SetWorldPosition(node_->GetWorldPosition());
particleStartNode_->SetScale(0.5f);
particleNode_ = particleStartNode_;
particleStartNode_->AddComponent(new SoundSource3D(context_), 0, LOCAL);
particleStartNode_->GetComponent<SoundSource3D>()->Play(main_->cache_->GetResource<Sound>("Sounds/93828__cgeffex__alien-voice8.ogg"));
}
}
}
示例7: SendEvent
void RangerSkill5::HandleHudButt(StringHash eventType, VariantMap& eventData)
{
UIElement* ele = static_cast<UIElement*>(eventData[HudButt::P_BUTT].GetPtr());
String name = ele->GetName();
if (name == "ranger")
{
skillSprite_->SetTexture(main_->cache_->
GetResource<Texture2D>("Textures/terriesHud/icons/ranger/S_Sword03.png"));
skillSprite_->SetOpacity(1.0f);
}
if (name == "skill5")
{
if (node_->HasComponent<Dead>())
{
return;
}
if (main_->mySceneNode_->GetComponent<SpriteSheetPlayer>()->focusedSprite_ == "ranger")
{
if (enabled_)
{
enabled_ = false;
node_->GetComponent<Armor>()->ModifyArmor(1, -1, false);
node_->GetComponent<Speed>()->speed_ -= 3.0f;
node_->RemoveChild(particleNode_);
return;
}
enabled_ = true;
if (node_->GetComponent<RangerSkill1>()->enabled_)
{
node_->GetComponent<RangerSkill1>()->enabled_ = false;
}
if (node_->GetComponent<RangerSkill0>()->enabled_)
{
node_->GetComponent<RangerSkill0>()->enabled_ = false;
node_->RemoveComponent<Stunned>();
}
node_->GetComponent<Armor>()->ModifyArmor(1, 1, false);
node_->GetComponent<Speed>()->speed_ += 3.0f;
Node* particleStartNode_ = node_->GetScene()->CreateChild(0,LOCAL);
ParticleEmitter* emitterStartFX_ = particleStartNode_->CreateComponent<ParticleEmitter>(LOCAL);
emitterStartFX_->SetEffect(main_->cache_->GetResource<ParticleEffect>("Particle/terriesWhirlwind.xml"));
emitterStartFX_->SetViewMask(1);
emitterStartFX_->SetEmitting(true);
node_->AddChild(particleStartNode_);
particleStartNode_->SetWorldPosition(node_->GetWorldPosition());
particleStartNode_->SetScale(0.5f);
particleNode_ = particleStartNode_;
particleStartNode_->AddComponent(new SoundSource3D(context_), 0, LOCAL);
particleStartNode_->GetComponent<SoundSource3D>()->SetGain(0.5f);
particleStartNode_->GetComponent<SoundSource3D>()->Play(main_->cache_->GetResource<Sound>("Sounds/106125__j1987__clickselect3.ogg"));
VariantMap vm;
vm[AnimateSceneNode::P_NODE] = node_;
if (node_->GetVar("sex").GetBool())
{
vm[AnimateSceneNode::P_ANIMATION] = "gestureF";
}
else
{
vm[AnimateSceneNode::P_ANIMATION] = "gestureM";
}
vm[AnimateSceneNode::P_LOOP] = false;
vm[AnimateSceneNode::P_LAYER] = 0;
SendEvent(E_ANIMATESCENENODE, vm);
}
}
}
示例8:
void RogueSkill5::HandleHudButt(StringHash eventType, VariantMap& eventData)
{
UIElement* ele = static_cast<UIElement*>(eventData[HudButt::P_BUTT].GetPtr());
String name = ele->GetName();
if (name == "rogue")
{
skillSprite_->SetTexture(main_->cache_->
GetResource<Texture2D>("Textures/terriesHud/icons/rogue/S_Dagger02.png"));
skillSprite_->SetOpacity(1.0f);
}
if (name == "skill5")
{
//if (cooling_){return;}
if (node_->HasComponent<Dead>())
{
return;
}
if (node_->GetComponent<RogueSkill0>()->enabled_)
{
return;
}
if (main_->mySceneNode_->GetComponent<SpriteSheetPlayer>()->focusedSprite_ == "rogue")
{
if (!enabled_)
{
enabled_ = true;
node_->GetComponent<Armor>()->ModifyArmor(10, -1, false);
int attack = node_->GetVar("attack").GetInt();
node_->SetVar("attack", attack + 100);
Node* particleStartNode_ = node_->GetScene()->CreateChild(0,LOCAL);
ParticleEmitter* emitterStartFX_ = particleStartNode_->CreateComponent<ParticleEmitter>(LOCAL);
emitterStartFX_->SetEffect(main_->cache_->GetResource<ParticleEffect>("Particle/terriesCrit.xml"));
emitterStartFX_->SetViewMask(1);
emitterStartFX_->SetEmitting(true);
node_->AddChild(particleStartNode_);
particleStartNode_->SetWorldPosition(node_->GetWorldPosition());
particleStartNode_->SetScale(0.5f);
particleNode_ = particleStartNode_;
particleStartNode_->AddComponent(new SoundSource3D(context_), 0, LOCAL);
particleStartNode_->GetComponent<SoundSource3D>()->SetGain(0.25f);
particleStartNode_->GetComponent<SoundSource3D>()->Play(main_->cache_->GetResource<Sound>("Sounds/170636__korgchops__8-bit-snare.ogg"));
}
else
{
enabled_ = false;
node_->GetComponent<Armor>()->ModifyArmor(10, 1, false);
int attack = node_->GetVar("attack").GetInt();
node_->SetVar("attack", attack - 100);
node_->RemoveChild(particleNode_);
}
VariantMap vm;
vm[AnimateSceneNode::P_NODE] = node_;
if (node_->GetVar("sex").GetBool())
{
vm[AnimateSceneNode::P_ANIMATION] = "gestureF";
}
else
{
vm[AnimateSceneNode::P_ANIMATION] = "gestureM";
}
vm[AnimateSceneNode::P_LOOP] = false;
vm[AnimateSceneNode::P_LAYER] = 0;
SendEvent(E_ANIMATESCENENODE, vm);
}
}
}
示例9: HandleButtonRelease
void GameMenu::HandleButtonRelease(StringHash eventType, VariantMap& eventData)
{
using namespace Released;
UIElement* ele = static_cast<UIElement*>(eventData[Released::P_ELEMENT].GetPtr());
network_->Disconnect();
if (ele->GetName() == "host")
{
VariantMap vm;
vm[GameMenuDisplay::P_STATE] = false;
SendEvent(E_GAMEMENUDISPLAY, vm);
if (main_->myRootNode_->HasComponent<Client>())
{
main_->myRootNode_->RemoveComponent(
main_->myRootNode_->GetComponent<Client>());
}
if (main_->myRootNode_->HasComponent<Server>())
{
main_->myRootNode_->RemoveComponent(
main_->myRootNode_->GetComponent<Server>());
}
main_->myRootNode_->AddComponent(new Server(context_, main_), 0, LOCAL);
}
else if (ele->GetName() == "list")
{
QueryMasterServer();
}
else if (ele->GetName() == "join")
{
VariantMap vm;
vm[GameMenuDisplay::P_STATE] = false;
SendEvent(E_GAMEMENUDISPLAY, vm);
if (main_->myRootNode_->HasComponent<Server>())
{
main_->myRootNode_->RemoveComponent(
main_->myRootNode_->GetComponent<Server>());
}
if (!main_->myRootNode_->HasComponent<Client>())
{
main_->myRootNode_->AddComponent(new Client(context_, main_), 0, LOCAL);
}
int index = ((ListView*)serverName_)->GetSelection();
if (index < 0)
{
network_->Connect(ipAddress_, 9002, 0);
return;
}
UIElement* item = ((ListView*)address_)->GetItem(index);
String address = ((Text*)item)->GetText();
network_->Connect(address, 9002, 0);
}
else if (ele->GetName() == "mainMenuButt")
{
VariantMap vm;
vm[GameMenuDisplay::P_STATE] = true;
SendEvent(E_GAMEMENUDISPLAY, vm);
}
}
示例10: TimedRemove
void RogueSkill0::HandleHudButt(StringHash eventType, VariantMap& eventData)
{
UIElement* ele = static_cast<UIElement*>(eventData[HudButt::P_BUTT].GetPtr());
String name = ele->GetName();
if (name == "rogue")
{
skillSprite_->SetTexture(main_->cache_->
GetResource<Texture2D>("Textures/terriesHud/icons/rogue/S_Shadow16.png"));
skillSprite_->SetOpacity(1.0f);
}
if (name == "skill0")
{
//if (cooling_){return;}
if (node_->HasComponent<Dead>())
{
return;
}
if (main_->mySceneNode_->GetComponent<SpriteSheetPlayer>()->focusedSprite_ == "rogue")
{
Node* particleStartNode_ = node_->GetScene()->CreateChild(0,LOCAL);
ParticleEmitter* emitterStartFX_ = particleStartNode_->CreateComponent<ParticleEmitter>(LOCAL);
emitterStartFX_->SetEffect(main_->cache_->GetResource<ParticleEffect>("Particle/terriesInvisibility.xml"));
emitterStartFX_->SetViewMask(1);
emitterStartFX_->SetEmitting(true);
node_->AddChild(particleStartNode_);
particleStartNode_->SetWorldPosition(node_->GetWorldPosition());
particleStartNode_->SetScale(0.5f);
particleStartNode_->AddComponent(new TimedRemove(context_, main_, 0.5f), 0, LOCAL);
particleStartNode_->AddComponent(new SoundSource3D(context_), 0, LOCAL);
particleStartNode_->GetComponent<SoundSource3D>()->Play(main_->cache_->GetResource<Sound>("Sounds/160756__cosmicembers__fast-swing-air-woosh.ogg"));
if (!enabled_)
{
node_->GetComponent<StaticSprite2D>()->GetCustomMaterial()->SetShaderParameter(
"MatDiffColor",Color(0.3f, 0.3f, 0.3f, 0.5f));
node_->GetComponent<Armor>()->ModifyArmor(1, 1, false);
node_->GetComponent<RigidBody>()->SetCollisionLayerAndMask(4,249);
enabled_ = true;
if (node_->GetComponent<RogueSkill2>()->enabled_)
{
node_->GetComponent<RogueSkill2>()->enabled_ = false;
}
if (node_->GetComponent<RogueSkill5>()->enabled_)
{
node_->GetComponent<RogueSkill5>()->enabled_ = false;
}
}
else
{
node_->GetComponent<StaticSprite2D>()->GetCustomMaterial()->SetShaderParameter(
"MatDiffColor",Color(0.3f, 0.3f, 0.3f, 1.0f));
node_->GetComponent<Armor>()->ModifyArmor(1, -1, false);
node_->GetComponent<RigidBody>()->SetCollisionLayerAndMask(2,-1);
enabled_ = false;
}
//Variant v = node_->GetComponent<StaticSprite2D>()->GetCustomMaterial()->GetShaderParameter("MatDiffColor");
//Color c = v.GetColor();LOGERRORF("%s",c.ToString().CString());
//c.a_ = 0.5f;
//node_->GetComponent<StaticSprite2D>()->GetCustomMaterial()->SetShaderParameter(
//"MatDiffColor",Color(0.3f, 0.3f, 0.3f, 0.5f));
/*elapsedTime_ = 0.0f;
durationElapsedTime_ = 0.0f;
processing_ = true;
cooling_ = true;*/
VariantMap vm;
vm[AnimateSceneNode::P_NODE] = node_;
if (node_->GetVar("sex").GetBool())
{
vm[AnimateSceneNode::P_ANIMATION] = "gestureF";
}
else
{
vm[AnimateSceneNode::P_ANIMATION] = "gestureM";
}
vm[AnimateSceneNode::P_LOOP] = false;
vm[AnimateSceneNode::P_LAYER] = 0;
SendEvent(E_ANIMATESCENENODE, vm);
}
}
}