本文整理汇总了C++中sf::Font::LoadFromFile方法的典型用法代码示例。如果您正苦于以下问题:C++ Font::LoadFromFile方法的具体用法?C++ Font::LoadFromFile怎么用?C++ Font::LoadFromFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::Font
的用法示例。
在下文中一共展示了Font::LoadFromFile方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawHud
void Player::drawHud(sf::RenderWindow& rw) const
{
static bool firstRun = true;
static sf::Font font;
if(firstRun)
{
firstRun = false;
font.LoadFromFile("silesiana.otf", 50, L"A�BC�DE�FGHIJKL�MN�O�PRS�TUWYZ��a�bc�de�fghijkl�mn�o�prs�tuwyz��[email protected]#$%^&*()_-[]\\;',./{}:\"<>?=-+ ");
}
sf::Sprite hud(hudimg, sf::Vector2f(0, 350));
rw.Draw(hud);
int hbarheight= health * hbarimg.GetHeight();
sf::Sprite hbar(hbarimg, sf::Vector2f(42, 376 + hbarimg.GetHeight() - hbarheight));
hbar.SetSubRect(sf::IntRect(0, hbarimg.GetHeight() - hbarheight, hbarimg.GetWidth(), hbarimg.GetHeight()));
rw.Draw(hbar);
std::wstring str;
for(int i=0;i<4;i++)
{
if(i<msgList.size())
str += msgList[i] + L"\n";
}
sf::String msgs(str, font, 30);
msgs.SetColor(sf::Color(120, 10, 10));
msgs.SetPosition(200, 450);
rw.Draw(msgs);
}
示例2: LoadFromFile
bool FontHandler::LoadFromFile(const typeAssetID theAssetID, sf::Font& theAsset)
{
// Start with a return result of false
bool anResult = false;
// Retrieve the filename for this asset
std::string anFilename = GetFilename(theAssetID);
// Was a valid filename found? then attempt to load the asset from anFilename
if(anFilename.length() > 0)
{
// Load the asset from a file
#if (SFML_VERSION_MAJOR < 2)
anResult = theAsset.LoadFromFile(anFilename);
#else
anResult = theAsset.loadFromFile(anFilename);
#endif
}
else
{
ELOG() << "FontHandler::LoadFromFile(" << theAssetID
<< ") No filename provided!" << std::endl;
}
// Return anResult of true if successful, false otherwise
return anResult;
}
示例3: drawAtributes
void Player::drawAtributes(sf::RenderWindow& rw) const
{
static bool firstRun = true;
static sf::Image tlo;
static sf::Font font;
if(firstRun)
{
tlo.LoadFromFile("Images/tlo.png");
firstRun = false;
font.LoadFromFile("silesiana.otf", 50, L"A�BC�DE�FGHIJKL�MN�O�PRS�TUWYZ��a�bc�de�fghijkl�mn�o�prs�tuwyz��[email protected]#$%^&*()_-[]\\;',./{}:\"<>?=-+ ");
}
sf::Sprite tloH(tlo);
rw.Draw(tloH);
std::wstringstream ss;
if(selectedAttribute == 0)
{
ss << L"Exp: " << xp << L"\n";
ss << L"> Poziom obrony: " << defLevel << L"\n";
ss << L"Poziom ataku: " << attLevel << L"\n";
}
else
{
ss << L"Exp: " << xp << L"\n";
ss << L"Poziom obrony: " << defLevel << L"\n";
ss << L"> Poziom ataku: " << attLevel << L"\n";
}
sf::String t(ss.str(), font, 30.f);
t.SetColor(sf::Color(20, 18, 160));
t.SetPosition(20.f, 20.0);
rw.Draw(t);
}
示例4: lire_Texte
void Param::lire_Texte(std::ifstream &fichier, sf::String &destination, sf::Font &myFont)
{
std::string ligne;
int x, y, z;
lire_string(fichier, ligne);
destination.SetText(traduire(ligne.c_str()));
lire_position(fichier, x, y);
destination.SetPosition(x, y);
lire_string(fichier, ligne);
if(ligne != "default" && !myFont.LoadFromFile(ligne))
{
std::cerr << "Erreur lors du chargement de la police '" << ligne << "'" << std::endl;
myFont = sf::Font::GetDefaultFont();
}
else if(ligne == "default")
myFont = sf::Font::GetDefaultFont();
lire_int(fichier, x);
destination.SetSize(x);
lire_string(fichier, ligne);
set_police(destination, ligne.c_str());
lire_couleur(fichier, x, y, z);
destination.SetColor(sf::Color(x, y, z));
lire_int(fichier, x);
destination.SetRotation(x);
}
示例5: log_setup_1
int log_setup_1(){
//Load Font
if( PTSANS_loaded == false ){
if (!PTSANS.LoadFromFile("PTN57F.ttf", 50)) return -1;
PTSANS_loaded = true;
}
//Setup Strings
log_string.SetFont( PTSANS );
log_string.SetSize(24.f);
log_string.SetColor( sf::Color(255, 255, 255) );
log_string.SetPosition(100.f, 600.f);
log_name.SetFont( PTSANS );
log_name.SetSize(40.f);
log_name.SetColor( sf::Color(255, 255, 255) );
log_name.SetPosition(100.f, 550.f);
}
示例6: load
bool FontManager::load(Path name, sf::Font & dst)
{
//Fetch the possible locations for this font.
DataManager::Paths paths = app->data.paths(Path("fonts") + name);
//Try to load the font.
bool success = false;
for (int i = 0; i < paths.size() && !success; i++) {
success = dst.LoadFromFile(paths[i].c_str(), 16);
}
//Return success.
if (success) {
LOG(DEBUG, "loaded font '%s'", name.c_str());
} else {
LOG(WARNING, "unable to find font '%s'", name.c_str());
}
return success;
}
示例7: drawInventory
void Player::drawInventory(sf::RenderWindow& rw) const
{
static bool firstRun = true;
static sf::Image tlo;
static sf::Font font;
if(firstRun)
{
tlo.LoadFromFile("Images/inv.png");
firstRun = false;
font.LoadFromFile("silesiana.otf", 50, L"A�BC�DE�FGHIJKL�MN�O�PRS�TUWYZ��a�bc�de�fghijkl�mn�o�prs�tuwyz��[email protected]#$%^&*()_-[]\\;',./{}:\"<>?=-+ ");
}
sf::Sprite tloH(tlo);
rw.Draw(tloH);
std::stringstream ss;
ss<<"Masz " << coins << " $";
sf::String t(ss.str(), font, 30.f);
t.SetColor(sf::Color(20, 18, 160));
t.SetPosition(600.f, 30.f);
rw.Draw(t);
float posy = 30.0;
int i = 0;
for(std::vector<Item>::const_iterator it = inventory.begin(); it != inventory.end(); it++)
{
std::wstring name = it->getName();
if(i == weapon)
{
name += L" (uzbrojny - bro�)";
}
if(i == armor)
{
name += L" (uzbrojny - zbroja)";
}
sf::String t(name, font, 30.f);
t.SetColor(sf::Color(20, 18, 160));
if(selectedItem == i)
t.SetColor(sf::Color(200, 18, 160));
t.SetPosition(20.f, posy);
rw.Draw(t);
posy += 30.0;
i++;
}
if(0 <= selectedItem && selectedItem < inventory.size())
{
TextArea desc(inventory[selectedItem].getDesc(), 400, font);
desc.SetPosition(300, 50);
rw.Draw(desc);
Item::Type type = inventory[selectedItem].getProperty();
if(type == 0)
{
TextArea desc1(L"Bron - Atak + " +inventory[selectedItem].getBoost(), 400,font);
desc1.SetPosition(350,250);
rw.Draw(desc1);
}
else if(type == 1)
{
TextArea desc1(L"Zbroja - Obrona + " +inventory[selectedItem].getBoost(), 400,font);
desc1.SetPosition(350,250);
rw.Draw(desc1);
}
else if(type == 2)
{
TextArea desc1(L"Helm - Obrona + " +inventory[selectedItem].getBoost(), 400,font);
desc1.SetPosition(350,250);
rw.Draw(desc1);
}
else if(type == 3)
{
TextArea desc1(L"Mikstura", 460,font);
desc1.SetPosition(350,250);
rw.Draw(desc1);
}
}
}
示例8: PrepareFont
void PrepareFont(sf::Font &MyFont)
{
MyFont.LoadFromFile(string(res_path)+string(font_name), 20);
}