本文整理汇总了C++中Text::SetText方法的典型用法代码示例。如果您正苦于以下问题:C++ Text::SetText方法的具体用法?C++ Text::SetText怎么用?C++ Text::SetText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Text
的用法示例。
在下文中一共展示了Text::SetText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateInstructions
void SignedDistanceFieldText::CreateInstructions()
{
ResourceCache* cache = GetSubsystem<ResourceCache>();
UI* ui = GetSubsystem<UI>();
// Construct new Text object, set string to display and font to use
Text* instructionText = ui->GetRoot()->CreateChild<Text>();
instructionText->SetText("Use WASD keys and mouse/touch to move");
instructionText->SetFont(cache->GetResource<Font>("Fonts/Anonymous Pro.ttf"), 15);
// Position the text relative to the screen center
instructionText->SetHorizontalAlignment(HA_CENTER);
instructionText->SetVerticalAlignment(VA_CENTER);
instructionText->SetPosition(0, ui->GetRoot()->GetHeight() / 4);
}
示例2: HandleDeath
void Character2D::HandleWoundedState(float timeStep)
{
auto* body = GetComponent<RigidBody2D>();
auto* animatedSprite = GetComponent<AnimatedSprite2D>();
// Play "hit" animation in loop
if (animatedSprite->GetAnimation() != "hit")
animatedSprite->SetAnimation("hit", LM_FORCE_LOOPED);
// Update timer
timer_ += timeStep;
if (timer_ > 2.0f)
{
// Reset timer
timer_ = 0.0f;
// Clear forces (should be performed by setting linear velocity to zero, but currently doesn't work)
body->SetLinearVelocity(Vector2::ZERO);
body->SetAwake(false);
body->SetAwake(true);
// Remove particle emitter
node_->GetChild("Emitter", true)->Remove();
// Update lifes UI and counter
remainingLifes_ -= 1;
auto* ui = GetSubsystem<UI>();
Text* lifeText = static_cast<Text*>(ui->GetRoot()->GetChild("LifeText", true));
lifeText->SetText(String(remainingLifes_)); // Update lifes UI counter
// Reset wounded state
wounded_ = false;
// Handle death
if (remainingLifes_ == 0)
{
HandleDeath();
return;
}
// Re-position the character to the nearest point
if (node_->GetPosition().x_ < 15.0f)
node_->SetPosition(Vector3(1.0f, 8.0f, 0.0f));
else
node_->SetPosition(Vector3(18.8f, 9.2f, 0.0f));
}
}
示例3: CreateButton
Button* Chat::CreateButton(const String& text, int width)
{
ResourceCache* cache = GetSubsystem<ResourceCache>();
Font* font = cache->GetResource<Font>("Fonts/Anonymous Pro.ttf");
Button* button = buttonContainer_->CreateChild<Button>();
button->SetStyleAuto();
button->SetFixedWidth(width);
Text* buttonText = button->CreateChild<Text>();
buttonText->SetFont(font, 12);
buttonText->SetAlignment(HA_CENTER, VA_CENTER);
buttonText->SetText(text);
return button;
}
示例4: HandleDragMove
void UIDrag::HandleDragMove(StringHash eventType, VariantMap& eventData)
{
using namespace DragBegin;
Button* element = (Button*)eventData[P_ELEMENT].GetVoidPtr();
int buttons = eventData[P_BUTTONS].GetInt();
IntVector2 d = element->GetVar("DELTA").GetIntVector2();
int X = eventData[P_X].GetInt() + d.x_;
int Y = eventData[P_Y].GetInt() + d.y_;
int BUTTONS = element->GetVar("BUTTONS").GetInt();
Text* t = (Text*)element->GetChild(String("Event Touch"));
t->SetText("Drag Move Buttons: " + String(buttons));
if (buttons == BUTTONS)
element->SetPosition(IntVector2(X, Y));
}
示例5:
void Urho2DSpriterAnimation::CreateInstructions()
{
ResourceCache* cache = GetSubsystem<ResourceCache>();
UI* ui = GetSubsystem<UI>();
// Construct new Text object, set string to display and font to use
Text* instructionText = ui->GetRoot()->CreateChild<Text>();
instructionText->SetText("Mouse click to play next animation, \nUse WASD keys to move, use PageUp PageDown keys to zoom.");
instructionText->SetFont(cache->GetResource<Font>("Fonts/Anonymous Pro.ttf"), 15);
instructionText->SetTextAlignment(HA_CENTER); // Center rows in relation to each other
// Position the text relative to the screen center
instructionText->SetHorizontalAlignment(HA_CENTER);
instructionText->SetVerticalAlignment(VA_CENTER);
instructionText->SetPosition(0, ui->GetRoot()->GetHeight() / 4);
}
示例6:
void Urho2DConstraints::CreateInstructions()
{
ResourceCache* cache = GetSubsystem<ResourceCache>();
UI* ui = GetSubsystem<UI>();
// Construct new Text object, set string to display and font to use
Text* instructionText = ui->GetRoot()->CreateChild<Text>();
instructionText->SetText("Use WASD keys and mouse to move, Use PageUp PageDown to zoom.\n Space to toggle debug geometry and joints - F5 to save the scene.");
instructionText->SetFont(cache->GetResource<Font>("Fonts/Anonymous Pro.ttf"), 15);
instructionText->SetTextAlignment(HA_CENTER); // Center rows in relation to each other
// Position the text relative to the screen center
instructionText->SetHorizontalAlignment(HA_CENTER);
instructionText->SetVerticalAlignment(VA_CENTER);
instructionText->SetPosition(0, ui->GetRoot()->GetHeight() / 4);
}
示例7: Intro
void Maze::Intro()
{
float windowWidth = (float)this->mGe->GetEngineParameters().windowWidth;
float windowHeight = (float)this->mGe->GetEngineParameters().windowHeight;
float dx = (windowHeight * 4.0f) / 3.0f;
float offSet = (windowWidth - dx) / 2.0f;
float textHalfWidth = (dx * (205.0f / 800.0f)) * 0.5f;
float y = this->mGe->GetEngineParameters().windowHeight * 0.4f;
Text* intro = mGe->CreateText("Maze", D3DXVECTOR2(dx * 0.5f - textHalfWidth + offSet, y), 2.0f, "Media/Fonts/1");
mGe->LoadingScreen("Media/LoadingScreen/LoadingScreenBG.png", "Media/LoadingScreen/LoadingScreenPB.png"); // Changed by MaloW
intro->SetText("");
mGe->DeleteText(intro);
this->mWindowWidth = (float)this->mGe->GetEngineParameters().windowWidth;
this->mWindowHeight = (float)this->mGe->GetEngineParameters().windowHeight;
this->mHud[0] = mGe->CreateText("",D3DXVECTOR2(0,0),1.25f,"Media/Fonts/1");
this->mHud[1] = mGe->CreateText("",D3DXVECTOR2(0,30),1.0f,"Media/Fonts/1");
this->mHud[2] = mGe->CreateText("",D3DXVECTOR2(0,60),1.0f,"Media/Fonts/1");
this->mHud[3] = mGe->CreateText("",D3DXVECTOR2(0,90),1.0f,"Media/Fonts/1");
this->mHud[4] = mGe->CreateText("",D3DXVECTOR2(0,120),1.25f,"Media/Fonts/1");
this->mHud[5] = mGe->CreateText("",D3DXVECTOR2(0,150),1.0f,"Media/Fonts/1");
this->mHud[6] = mGe->CreateText("",D3DXVECTOR2(0,180),1.0f,"Media/Fonts/1");
this->mHud[7] = mGe->CreateText("",D3DXVECTOR2(0,210),1.0f,"Media/Fonts/1");
this->mHud[8] = mGe->CreateText("",D3DXVECTOR2(0,240),1.0f,"Media/Fonts/1");
this->mHud[9] = mGe->CreateText("",D3DXVECTOR2(0,270),1.0f,"Media/Fonts/1");
this->mCreditSpeed = 0.05f;
/*
if(mGe->GetEngineParameters().CamType == TRD)
((TRDCamera*)mGe->GetCamera())->setBallToFollow(this->mBalls[0]);
*/
this->mTimeElapsedText = this->mGe->CreateText( "",
D3DXVECTOR2(windowWidth - 150.0f,
windowHeight - 100.0f),
1.0f,
"Media/Fonts/1");
/*
CheckBox for the change gamemode
*/
this->mCb = new CheckBox(0,0,0,"Media/Menus/CheckBoxFrame.png", dx * (30.0f / 1200.0f), windowHeight * (30.0f / 900.0f),
"Media/Menus/CheckBoxChecked.png", true, new ChangeOptionEvent("MazeMode", "true"), "ChangeSet");
}
示例8: UpdatePanel
void ProfilerHudPanel::UpdatePanel(float /*frametime*/, const SharedPtr<Urho3D::UIElement> &widget)
{
if (profilerTimer_.GetMSec(false) < profilerInterval)
return;
Profiler* profiler = framework_->GetSubsystem<Profiler>();
Text *profilerText = dynamic_cast<Text*>(widget.Get());
if (!profiler || !profilerText)
return;
profilerTimer_.Reset();
String profilerOutput = profiler->PrintData(false, false, profilerMaxDepth);
profilerText->SetText(profilerOutput);
profiler->BeginInterval();
}
示例9: InitWindow
void HelloGUI::InitWindow()
{
// Create the Window and add it to the UI's root node
window_ = new Window(context_);
uiRoot_->AddChild(window_);
// Set Window size and layout settings
window_->SetMinSize(384, 192);
window_->SetLayout(LM_VERTICAL, 6, IntRect(6, 6, 6, 6));
window_->SetAlignment(HA_CENTER, VA_CENTER);
window_->SetName("Window");
// Create Window 'titlebar' container
UIElement* titleBar = new UIElement(context_);
titleBar->SetMinSize(0, 24);
titleBar->SetVerticalAlignment(VA_TOP);
titleBar->SetLayoutMode(LM_HORIZONTAL);
// Create the Window title Text
Text* windowTitle = new Text(context_);
windowTitle->SetName("WindowTitle");
windowTitle->SetText("Hello GUI!");
// Create the Window's close button
Button* buttonClose = new Button(context_);
buttonClose->SetName("CloseButton");
// Add the controls to the title bar
titleBar->AddChild(windowTitle);
titleBar->AddChild(buttonClose);
// Add the title bar to the Window
window_->AddChild(titleBar);
// Apply styles
window_->SetStyleAuto();
windowTitle->SetStyleAuto();
buttonClose->SetStyle("CloseButton");
// Subscribe to buttonClose release (following a 'press') events
SubscribeToEvent(buttonClose, E_RELEASED, HANDLER(HelloGUI, HandleClosePressed));
// Subscribe also to all UI mouse clicks just to see where we have clicked
SubscribeToEvent(E_UIMOUSECLICK, HANDLER(HelloGUI, HandleControlClicked));
}
示例10: CreateInstructions
void UIDrag::CreateInstructions()
{
ResourceCache* cache = GetSubsystem<ResourceCache>();
UI* ui = GetSubsystem<UI>();
// Construct new Text object, set string to display and font to use
Text* instructionText = ui->GetRoot()->CreateChild<Text>();
instructionText->SetText("Drag on the buttons to move them around.\n"
"Touch input allows also multi-drag.\n"
"Press SPACE to show/hide tagged UI elements.");
instructionText->SetFont(cache->GetResource<Font>("Fonts/Anonymous Pro.ttf"), 15);
instructionText->SetTextAlignment(HA_CENTER);
// Position the text relative to the screen center
instructionText->SetHorizontalAlignment(HA_CENTER);
instructionText->SetVerticalAlignment(VA_CENTER);
instructionText->SetPosition(0, ui->GetRoot()->GetHeight() / 4);
}
示例11: 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 + "!");
}
示例12: PopulateInterpreter
bool Console::PopulateInterpreter()
{
interpreters_->RemoveAllItems();
EventReceiverGroup* group = context_->GetEventReceivers(E_CONSOLECOMMAND);
if (!group || group->receivers_.Empty())
return false;
Vector<String> names;
for (unsigned i = 0; i < group->receivers_.Size(); ++i)
{
Object* receiver = group->receivers_[i];
if (receiver)
names.Push(receiver->GetTypeName());
}
Sort(names.Begin(), names.End());
unsigned selection = M_MAX_UNSIGNED;
for (unsigned i = 0; i < names.Size(); ++i)
{
const String& name = names[i];
if (name == commandInterpreter_)
selection = i;
Text* text = new Text(context_);
text->SetStyle("ConsoleText");
text->SetText(name);
interpreters_->AddItem(text);
}
const IntRect& border = interpreters_->GetPopup()->GetLayoutBorder();
interpreters_->SetMaxWidth(interpreters_->GetListView()->GetContentElement()->GetWidth() + border.left_ + border.right_);
bool enabled = interpreters_->GetNumItems() > 1;
interpreters_->SetEnabled(enabled);
interpreters_->SetFocusMode(enabled ? FM_FOCUSABLE_DEFOCUSABLE : FM_NOTFOCUSABLE);
if (selection == M_MAX_UNSIGNED)
{
selection = 0;
commandInterpreter_ = names[selection];
}
interpreters_->SetSelection(selection);
return true;
}
示例13: CreateButton
Button* SoundEffects::CreateButton(int x, int y, int xSize, int ySize, const String& text)
{
UIElement* root = GetSubsystem<UI>()->GetRoot();
ResourceCache* cache = GetSubsystem<ResourceCache>();
Font* font = cache->GetResource<Font>("Fonts/Anonymous Pro.ttf");
// Create the button and center the text onto it
Button* button = root->CreateChild<Button>();
button->SetStyleAuto();
button->SetPosition(x, y);
button->SetSize(xSize, ySize);
Text* buttonText = button->CreateChild<Text>();
buttonText->SetAlignment(HA_CENTER, VA_CENTER);
buttonText->SetFont(font, 12);
buttonText->SetText(text);
return button;
}
示例14: Intro
void CaptureTheFlag::Intro()
{
float windowWidth = (float)this->mGe->GetEngineParameters().windowWidth;
float windowHeight = (float)this->mGe->GetEngineParameters().windowHeight;
float dx = (windowHeight * 4.0f) / 3.0f;
float offSet = (windowWidth - dx) / 2.0f;
float textHalfWidth = (dx * (675.0f / 800.0f)) * 0.5f;
float y = this->mGe->GetEngineParameters().windowHeight * 0.4f;
Text* intro = mGe->CreateText("Capture The Flag", D3DXVECTOR2(dx * 0.5f - textHalfWidth + offSet, y), 2.0f,"Media/Fonts/1");
mGe->LoadingScreen("Media/LoadingScreen/LoadingScreenBG.png", "Media/LoadingScreen/LoadingScreenPB.png"); // Changed by MaloW
intro->SetText("");
mGe->DeleteText(intro);
//net while(this->mChooseTeamMenu->Run());
// Moved down by malow
windowWidth = (float)this->mGe->GetEngineParameters().windowWidth;
windowHeight = (float)this->mGe->GetEngineParameters().windowHeight;
dx = (windowHeight * 4.0f) / 3.0f;
offSet = (windowWidth - dx) / 2.0f;
textHalfWidth = dx * (200.0f / 800.0f);
float x = this->mGe->GetEngineParameters().windowWidth * 0.5f - textHalfWidth;
y = 10.0f;
this->mIntermediateText = this->mGe->CreateText("", D3DXVECTOR2(dx * 0.5f - textHalfWidth + offSet, y), 1.0f, "Media/Fonts/1");
x = this->mGe->GetEngineParameters().windowWidth * 0.5f - textHalfWidth - this->mGe->GetEngineParameters().windowWidth * 0.1f - this->mGe->GetEngineParameters().windowWidth * 0.025f;
this->mRedScoreText = this->mGe->CreateText("", D3DXVECTOR2(x, y), 1.0f, "Media/Fonts/3");
x = this->mGe->GetEngineParameters().windowWidth * 0.5f + textHalfWidth + this->mGe->GetEngineParameters().windowWidth * 0.1f;
this->mBlueScoreText = this->mGe->CreateText("", D3DXVECTOR2(x, y), 1.0f, "Media/Fonts/2");
x = this->mGe->GetEngineParameters().windowWidth * 0.5f - this->mGe->GetEngineParameters().windowWidth * 0.4f;
y = this->mGe->GetEngineParameters().windowHeight * 0.4f;
this->mHud[0] = this->mGe->CreateText("", D3DXVECTOR2(x, y), 2.0f, "Media/Fonts/1");
//
this->mRedScoreText->SetText("0");
this->mBlueScoreText->SetText("0");
string totalScore = MaloW::convertNrToString((float)this->mNumberOfRounds);
this->mIntermediateText->SetText("Flags captured of " + totalScore);
}
示例15: CreateInstructions
void Sample::CreateInstructions()
{
ResourceCache* cache = GetSubsystem<ResourceCache>();
UI* ui = GetSubsystem<UI>();
// Construct new Text object, set string to display and font to use
Text* instructionText = ui->GetRoot()->CreateChild<Text>();
instructionText->SetText(
"Use WASD keys and mouse to move\n"
"Space to toggle debug geometry"
);
instructionText->SetFont(cache->GetResource<Font>("Fonts/Anonymous Pro.ttf"), 13);
// The text has multiple rows. Center them in relation to each other
instructionText->SetTextAlignment(HA_CENTER);
// Position the text relative to the screen center
instructionText->SetHorizontalAlignment(HA_CENTER);
instructionText->SetVerticalAlignment(VA_CENTER);
instructionText->SetPosition(0, ui->GetRoot()->GetHeight() / 4);
}