本文整理汇总了C++中Text::SetString方法的典型用法代码示例。如果您正苦于以下问题:C++ Text::SetString方法的具体用法?C++ Text::SetString怎么用?C++ Text::SetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Text
的用法示例。
在下文中一共展示了Text::SetString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
}
activeBrick = previewBrick;
activeBrick.SetActivePosition();
previewBrick = PullBrickFromQueue(&brickQueue);
previewBrick.SetPreviewPosition();
}
else
{
Time fallTimer = brickFallTimer.GetElapsedTime();
Time lockTimer = brickLockTimer.GetElapsedTime();
float dropSpeed = 1 - (float)(level * 0.05f);
if (!IsBottomCollision(activeBrick, gameBoard) && fallTimer.AsSeconds() >= dropSpeed)
{
for (int i = 0; i < SPRITES_IN_BRICK; i++)
{
activeBrick.SetSpriteYPosition(i, 1);
brickFallTimer.Restart();
isCheckingLockTime = false;
}
}
else if (IsBottomCollision(activeBrick, gameBoard))
{
if (!isCheckingLockTime)
{
isCheckingLockTime = true;
brickLockTimer.Restart();
}
else if (lockTimer.AsSeconds() >= 0.5f)
{
activeBrick.LockBrick();
isCheckingLockTime = false;
}
}
}
while (renderWindow.PollEvent(gameEvent))
{
if (gameEvent.Type == Event::Closed || gameEvent.Key.Code == Keyboard::Escape)
{
renderWindow.Close();
}
if (gameEvent.Type == Event::KeyPressed)
{
CheckInput(&gameEvent, &activeBrick, gameBoard, &score);
}
}
scoreDisplayText.SetString(_itoa(score, scoreDisplayBuffer, 10));
levelDisplayText.SetString(_itoa(level, levelDisplayBuffer, 10));
for (int i = 0; i < NUMBER_OF_BRICK_TYPES; i++)
{
brickCountText[i].SetString(_itoa(brickCount[i], brickCountTextBuffer[i], 10));
}
renderWindow.Clear(Color(0, 255, 255));
renderWindow.Draw(backgroundSprite);
renderWindow.Draw(scoreHeaderText);
renderWindow.Draw(scoreDisplayText);
renderWindow.Draw(levelHeaderText);
renderWindow.Draw(levelDisplayText);
renderWindow.Draw(brickPreviewSprite);
renderWindow.Draw(nextBrickText);
for (int i = 0; i < NUMBER_OF_BRICK_TYPES; i++)
{
renderWindow.Draw(brickCountText[i]);
}
for (int i = 0; i < brickList.size(); i++)
{
for (int j = 0; j < SPRITES_IN_BRICK; j++)
{
renderWindow.Draw(brickList[i].GetSpriteArray()[j]);
}
}
for (int i = 0; i < SPRITES_IN_BRICK; i++)
{
renderWindow.Draw(activeBrick.GetSpriteArray()[i]);
renderWindow.Draw(previewBrick.GetSpriteArray()[i]);
}
renderWindow.Display();
break;
} //END CASE
} //END SWITCH
} //END GAME LOOP
return 0;
}
示例2: RefreshSizeWrap
void Text::RefreshSizeWrap()
{
RemoveAllChildren();
for( TextLines::const_iterator it = m_Lines.begin(), end = m_Lines.end(); it != end; ++it )
{
Text *t = *it;
delete t, t = 0;
}
m_Lines.clear();
std::vector<Gwen::UnicodeString> words;
SplitWords( GetText().GetUnicode(), L' ', words );
// Adding a bullshit word to the end simplifies the code below
// which is anything but simple.
words.push_back( L"" );
if ( !GetFont() )
{
Debug::AssertCheck( 0, "Text::RefreshSize() - No Font!!\n" );
return;
}
Point pFontSize = GetSkin()->GetRender()->MeasureText( GetFont(), L" " );
int w = GetParent()->Width();
int x = 0, y = 0;
Gwen::UnicodeString strLine;
std::vector<Gwen::UnicodeString>::iterator it = words.begin();
for ( it; it != words.end(); ++it )
{
bool bFinishLine = false;
bool bWrapped = false;
// If this word is a newline - make a newline (we still add it to the text)
if ( (*it).c_str()[0] == L'\n' ) bFinishLine = true;
// Does adding this word drive us over the width?
{
strLine += (*it);
Gwen::Point p = GetSkin()->GetRender()->MeasureText( GetFont(), strLine );
if ( p.x > Width() ) { bFinishLine = true; bWrapped = true; }
}
// If this is the last word then finish the line
if ( --words.end() == it )
{
bFinishLine = true;
}
if ( bFinishLine )
{
Text* t = new Text( this );
t->SetFont( GetFont() );
t->SetString( strLine.substr( 0, strLine.length() - (*it).length() ) );
t->RefreshSize();
t->SetPos( x, y );
m_Lines.push_back( t );
// newline should start with the word that was too big
strLine = *it;
// Position the newline
y += pFontSize.y;
x = 0;
//if ( strLine[0] == L' ' ) x -= pFontSize.x;
}
}
// Size to children height and parent width
{
Point childsize = ChildrenSize();
SetSize( w, childsize.y );
}
InvalidateParent();
Invalidate();
}
示例3: RefreshSizeWrap
void Text::RefreshSizeWrap()
{
RemoveAllChildren();
for ( TextLines::iterator it = m_Lines.begin(); it != m_Lines.end(); ++it )
{
delete *it;
}
m_Lines.clear();
std::vector<Gwen::UnicodeString> words;
SplitWords( GetText().GetUnicode(), words );
// Adding a bullshit word to the end simplifies the code below
// which is anything but simple.
words.push_back( L"" );
if ( !GetFont() )
{
Debug::AssertCheck( 0, "Text::RefreshSize() - No Font!!\n" );
return;
}
Point pFontSize = GetSkin()->GetRender()->MeasureText( GetFont(), L" " );
int w = GetParent()->Width() - GetParent()->GetPadding().left-GetParent()->GetPadding().right;
int x = 0, y = 0;
Gwen::UnicodeString strLine;
for ( std::vector<Gwen::UnicodeString>::iterator it = words.begin(); it != words.end(); ++it )
{
bool bFinishLine = false;
bool bWrapped = false;
// If this word is a newline - make a newline (we still add it to the text)
if ( ( *it ).c_str() [0] == L'\n' ) { bFinishLine = true; }
// Does adding this word drive us over the width?
{
strLine += ( *it );
Gwen::Point p = GetSkin()->GetRender()->MeasureText( GetFont(), strLine );
if ( p.x > w ) { bFinishLine = true; bWrapped = true; }
}
// If this is the last word then finish the line
if ( --words.end() == it )
{
bFinishLine = true;
}
if ( bFinishLine )
{
Text* t = new Text( this );
t->SetFont( GetFont() );
t->SetTextColor( m_Color );
if(bWrapped)
{
t->SetString( strLine.substr( 0, strLine.length() - (*it).length() ) );
// newline should start with the word that was too big
strLine = *it;
}
else
{
t->SetString( strLine.substr( 0, strLine.length()) );
//new line is empty
strLine.clear();
}
t->RefreshSize();
t->SetPos( x, y );
m_Lines.push_back( t );
// newline should start with the word that was too big
// strLine = *it;
// Position the newline
y += pFontSize.y;
x = 0;
//if ( strLine[0] == L' ' ) x -= pFontSize.x;
}
}
// Size to children height and parent width
Point childsize = ChildrenSize();
{
SetSize( w, childsize.y );
}
// Align the text within the parent
int y_offset = 0;
for ( TextLines::iterator it = m_Lines.begin(); it != m_Lines.end(); ++it )
{
Text* text = *it;
const Rect & bounds = GetInnerBounds();
int x = 0;
int y = 0;
if ( m_iAlign & Pos::Left ) { x = bounds.x; }
if ( m_iAlign & Pos::Right ) { x = bounds.x + ( bounds.w - text->Width() ); }
if ( m_iAlign & Pos::CenterH ) { x = bounds.x + ( bounds.w - text->Width() ) * 0.5; }
if ( m_iAlign & Pos::Top ) { y = bounds.y; }
//.........这里部分代码省略.........
示例4: RefreshSizeWrap
void Text::RefreshSizeWrap()
{
RemoveAllChildren();
m_Lines.clear();
stl::vector<Gwen::String> words;
SplitWords( GetText().Get(), ' ', words );
// Adding a bullshit word to the end simplifies the code below
// which is anything but simple.
words.push_back( "" );
if ( !GetFont() )
{
Debug::AssertCheck( 0, "Text::RefreshSize() - No Font!!\n" );
return;
}
Point pFontSize = GetSkin()->GetRender()->MeasureText( GetFont(), " " );
int w = GetParent()->Width();
int x = 0, y = 0;
Gwen::String strLine;
stl::vector<Gwen::String>::iterator it = words.begin();
for (; it != words.end(); ++it )
{
bool bFinishLine = false;
//bool bWrapped = false;
// If this word is a newline - make a newline (we still add it to the text)
if ( (*it).c_str()[0] == '\n' ) bFinishLine = true;
// Does adding this word drive us over the width?
{
strLine += (*it);
Gwen::Point p = GetSkin()->GetRender()->MeasureText( GetFont(), strLine );
if ( p.x > Width() ) {
bFinishLine = true; /*bWrapped = true;*/
}
}
// If this is the last word then finish the line
// if ( --words.end() == it )
// NOTE: replaced above commented out 'if' statement with this to appease
// the GCC compiler that comes with Marmalade SDK 6.0
stl::vector<Gwen::String>::iterator temp = words.end() - 1;
if ( temp == it )
{
bFinishLine = true;
}
if ( bFinishLine )
{
Text* t = new Text( this );
t->SetFont( GetFont() );
t->SetString( strLine.substr( 0, strLine.length() - (*it).length() ) );
t->RefreshSize();
t->SetPos( x, y );
m_Lines.push_back( t );
// newline should start with the word that was too big
strLine = *it;
// Position the newline
y += pFontSize.y;
x = 0;
//if ( strLine[0] == ' ' ) x -= pFontSize.x;
}
}
// Size to children height and parent width
{
Point childsize = ChildrenSize();
SetSize( w, childsize.y );
}
InvalidateParent();
Invalidate();
}