本文整理汇总了C++中BitmapFont类的典型用法代码示例。如果您正苦于以下问题:C++ BitmapFont类的具体用法?C++ BitmapFont怎么用?C++ BitmapFont使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BitmapFont类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawMusicVolume
void OptionsState::DrawMusicVolume()
{
BitmapFont* font = Game::GetInstance()->GetFont();
std::string tempString = std::to_string(Game::GetInstance()->GetMusicVolume());
const char* vol = tempString.c_str();
font->Draw(vol, SGD::Point{ 450, 340 }, 0.7f);
}
示例2: reset
inline void reset(const BitmapFont& mBF)
{
xMin = xMax = yMin = yMax = 0;
iX = iY = chCount = 0;
width = mBF.getCellWidth();
height = mBF.getCellHeight();
}
示例3: BitmapFont
//---------------------------------------------------------------------------
STATIC BitmapFont* BitmapFont::CreateAndGetFont( const std::string& metaDataFilePath )
{
BitmapFont* result = new BitmapFont();
bool didLoad = result->LoadMetaDataWithTinyXML( metaDataFilePath );
if ( !didLoad )
{
delete result;
result = nullptr;
}
return result;
}
示例4: reset
inline void reset(const BitmapFont& mBF) noexcept
{
rDatas.clear();
xMin = xMax = yMin = yMax = nextHChunkSpacing = 0.f;
width = mBF.getCellWidth();
height = mBF.getCellHeight();
iX = 0;
nl = htab = vtab = 0;
}
示例5: RenderMainMenu
//-----------------------------------------------------------------------------------
void TheGame::RenderMainMenu()
{
if (m_mainMenuText == nullptr)
{
MeshBuilder builder;
BitmapFont* bmFont = BitmapFont::CreateOrGetFontFromGlyphSheet("Runescape");
builder.AddText2D(Vector2(450, 600), "Picougelike", 7.0f, RGBA::VAPORWAVE, true, bmFont);
builder.AddText2D(Vector2(450, 300), "New Game (N)", 5.0f, RGBA::CYAN, true, bmFont);
builder.AddText2D(Vector2(450, 150), "Quit (Q)", 5.0f, RGBA::CYAN, true, bmFont);
m_mainMenuText = new MeshRenderer(new Mesh(), bmFont->GetMaterial());
builder.CopyToMesh(m_mainMenuText->m_mesh, &Vertex_TextPCT::Copy, sizeof(Vertex_TextPCT), &Vertex_TextPCT::BindMeshToVAO);
}
m_mainMenuText->Render();
}
示例6: ReportError
bool GUIButton::Load(File* f, GUIElement* parent)
{
GUIElement::Load(f, parent);
BitmapFont* b = new BitmapFont;
if(!b->Load(f, this))
{
ReportError("GUI Button load fail, could not load bitmap font!");
return false;
}
m_pButtonText = b;
return true;
/*
std::string font;
std::string message;
UInt xCells, yCells = 0;
if(!f->GetString(&font))
{
ReportError("GUI Button load fail. Could not find button font texture");
return false;
}
if(!f->GetString(&message))
{
ReportError("GUI Button load fail. Could not find button text!");
return false;
}
if(!f->GetUInt(&xCells))
{
ReportError("GUI Button load fail. Could not find xCells number!");
return false;
}
if(!f->GetUInt(&yCells))
{
ReportError("GUI Button load fail. Could not find yCells number!");
return false;
}
m_pButtonText = new BitmapFont(font, message, xCells, yCells);
m_pButtonText->SetPosOffset(m_posOffset);
m_pButtonText->SetDimensions(m_dimensions);
m_pButtonText->SetParent(this);
return true;
*/
}
示例7: transform
BitmapText::BitmapText(const std::string& string, const BitmapFont &font) {
m_font = &font;
m_vertices = sf::VertexArray(sf::Quads);
m_string = transform(string);
m_color = sf::Color::White;
m_characterSize = font.getGlyphSize().y;
m_lineSpacing = 0.5f;
init();
}
示例8: BitmapFont
BitmapFont *BitmapFont::FromLua(LuaManager* Lua, std::string TableName)
{
BitmapFont* Ret = new BitmapFont();
Lua->UseArray(TableName);
Directory Locat = Lua->GetFieldS("Location", GameState::GetInstance().GetSkinPrefix() + "font.tga");
int CharWidth = Lua->GetFieldI("CharWidth");
int CharHeight = Lua->GetFieldI("CharHeight");
int CellWidth = Lua->GetFieldI("CellWidth");
int CellHeight = Lua->GetFieldI("CellHeight");
int RenderWidth = Lua->GetFieldI("RenderWidth");
int RenderHeight = Lua->GetFieldI("RenderHeight");
int FontStart = Lua->GetFieldI("FontStart");
Lua->Pop();
Ret->LoadFontImage(Locat.c_path(), Vec2(CharWidth, CharHeight), Vec2(CellWidth, CellHeight), Vec2(RenderWidth, RenderHeight), FontStart);
return Ret;
}
示例9: BitmapFont
BitmapFont* ResourceManager::LoadFont(const char* a_ccFont)
{
if(m_pFontMap.find(a_ccFont) == m_pFontMap.end())
{
BitmapFont* pFont = new BitmapFont();
if (!(pFont->LoadFont(a_ccFont)))
{
printf("Failed to load file: %s \n", a_ccFont);
return nullptr;
}
m_pFontMap.insert(std::pair<const char*, BitmapFont*>(a_ccFont, pFont));
return pFont;
}
else
{
return m_pFontMap[a_ccFont];
}
}
示例10: BitmapFont
bool TextManager::addFont(std::string key, char* fileName) {
if(key == "\0" && key == "\n") {
Log::get()->err("Font Create Fail: invalid key");
return false;
}
BitmapFont* font = new BitmapFont(m_pRender);
if(!font) {
Log::get()->err("BitmapFont Allocation Failed");
return false;
}
if(!font->init(fileName)) {
Log::get()->err("font->init(%s) Failed", fileName);
return false;
}
fontMap[key] = font;
return true;
}
示例11: drawMessages
void MessageSystem::drawMessages(Window& window, BitmapFont& font,
const std::vector<Message>& messages, int currentTurn)
{
font.setArea(GUI::getMessageArea(window));
for (int end = int(messages.size()), i = std::max(0, end - maxMessagesToPrint); i < end; ++i)
{
bool isNewMessage = messages[i].turn >= currentTurn - 1;
auto color = isNewMessage ? White : Gray;
font.print(window, "- ", color);
std::string text = messages[i].text;
if (messages[i].count > 1)
text += " (x" + std::to_string(messages[i].count) + ")";
font.printLine(window, text, color, Color::none, true, SplitLines);
}
#ifdef DEBUG
font.setArea(GUI::getDebugMessageArea(window));
for (const DebugMessage& message : debugMessages)
font.printLine(window, message.content, messageColors[message.type]);
#endif
}
示例12: SetFont
void BitmapString::SetFont(const BitmapFont& font)
{
if (&font != font_)
{
font_ = &font;
char_width_ = font.GetCharWidth();
for (size_t i = 0; i < bitmaps_.size(); ++i)
{
sf::Sprite& sprite = bitmaps_[i];
sprite.SetX(i * char_width_);
sprite.SetSubRect(font_->GetCharRect(chars_[i]));
sprite.SetImage(font_->GetImage());
}
}
}
示例13: BitmapGlyphInitializeLayoutData
friend void BitmapGlyphInitializeLayoutData(
BitmapGlyphRenderingBase& that,
BitmapGlyphLayoutData& layout_data,
BitmapFont& font,
const CodePoint* cps,
GLsizei length
)
{
OGLPLUS_FAKE_USE(that);
assert(layout_data._storage);
BitmapGlyphLayoutStorage& _storage = *layout_data._storage;
std::vector<GLfloat> x_offsets;
GLfloat width = font.QueryXOffsets(cps, length, x_offsets);
_storage.Initialize(
layout_data,
width,
x_offsets,
cps,
length
);
}
示例14: Render
void OptionsState::Render(float elapsedTime)
{
SGD::GraphicsManager::GetInstance()->DrawTexture(Game::GetInstance()->GetMenuBackground(), SGD::Point{ 0, 0 });
BitmapFont* font = Game::GetInstance()->GetFont();
font->Draw("Options", SGD::Point{ 335, 100 }, 1.5f);
font->Draw("Music Volume", SGD::Point{ 350, 300 }, 0.7f, SGD::Color{ 235, 255, 0 });
//font->Draw((char*)(GetMusicVolume()), SGD::Point{ 500, 300 }, 1.0f, SGD::Color{ 255, 255, 0 });
// no numbers? WAII?!
font->Draw("Sound Effects Volume", SGD::Point{ 350, 380 }, 0.7f, SGD::Color{ 235, 255, 0 });
font->Draw("Exit", SGD::Point{ 350, 460 }, 0.7f, SGD::Color{ 235, 255, 0 });
font->Draw("0", SGD::Point{ 310, 300.0f + 80 * m_iCursor }, 0.7f, SGD::Color{ 235, 255, 255 });
DrawMusicVolume();
DrawSfxVolume();
DrawSoundBars();
}
示例15: Render
void StatTracker::Render(float y)
{
BitmapFont* pFont = Game::GetInstance()->GetFont();
SGD::Point pos;
pos.x = 200;
pos.y = y;
std::stringstream display;
// Total Time Played
int timePlayed = (int)m_fTimePlayed;
display << "Total Time Played:";
pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } );
Increment(pos, display);
int days = timePlayed / 86400;
timePlayed -= days * 86400;
display << "\t\t";
display << days;
display << " Days";
pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } );
Increment(pos, display);
int hours = timePlayed / 3600;
timePlayed -= hours * 3600;
display << "\t\t";
display << hours;
display << " Hours";
pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } );
Increment(pos, display);
int minutes = timePlayed / 60;
timePlayed -= minutes * 60;
display << "\t\t";
display << minutes;
display << " Minutes";
pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } );
Increment(pos, display);
display << "\t\t";
display << timePlayed;
display << " Seconds";
pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } );
Increment(pos, display, 3);
// Build Phase Time
Increment(pos, display);
display << "Build Phase Time:";
pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } );
timePlayed = (int)m_fBuildPhaseTime;
Increment(pos, display);
days = timePlayed / 86400;
timePlayed -= days * 86400;
display << "\t\t";
display << days;
display << " Days";
pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } );
Increment(pos, display);
hours = timePlayed / 3600;
timePlayed -= hours * 3600;
display << "\t\t";
display << hours;
display << " Hours";
pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } );
Increment(pos, display);
minutes = timePlayed / 60;
timePlayed -= minutes * 60;
display << "\t\t";
display << minutes;
display << " Minutes";
pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } );
Increment(pos, display);
display << "\t\t";
display << timePlayed;
display << " Seconds";
pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } );
Increment(pos, display, 3);
// Survival Phase Time
Increment(pos, display);
display << "Survival Phase Time:";
pFont->Draw ( display.str ().c_str () , (int)pos.x , (int)pos.y , 0.5f , { 0 , 0 , 0 } );
timePlayed = (int)m_fSurvivalTime;
Increment(pos, display);
days = timePlayed / 86400;
timePlayed -= days * 86400;
display << "\t\t";
display << days;
//.........这里部分代码省略.........