本文整理汇总了C++中sf::Text::setCharacterSize方法的典型用法代码示例。如果您正苦于以下问题:C++ Text::setCharacterSize方法的具体用法?C++ Text::setCharacterSize怎么用?C++ Text::setCharacterSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::Text
的用法示例。
在下文中一共展示了Text::setCharacterSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void init() {
this->restart();
// RectangleShapes
sf::Vector2f unit(unit_w, unit_h);
stone_view = sf::RectangleShape(unit);
stone_view.setFillColor(sf::Color(255, 81, 68));
body_view = sf::RectangleShape(unit);
body_view.setFillColor(sf::Color(0, 204, 255));
food_view = sf::RectangleShape(unit);
food_view.setFillColor(sf::Color(19, 169, 136));
// font & msg
if (!font.loadFromFile("Inconsolata-Bold.ttf")) {
puts("fonts loading error!");
this->close();
}
msg1.setFont(font);
msg1.setColor(sf::Color::White);
msg1.setCharacterSize(50);
msg1.setPosition(80, 100);
msg2.setFont(font);
msg2.setColor(sf::Color::White);
msg2.setCharacterSize(25);
msg2.setString("Press <Enter> to Replay");
msg2.setPosition(60, 250);
}
示例2: initialize
void initialize(sf::RenderWindow &mainWindow, sf::Font &mainFont)
{
titleText.setFont(mainFont);
titleText.setString("Triangle Super");
titleText.setCharacterSize(72);
titleText.setPosition(mainWindow.getSize().x/2 - titleText.getGlobalBounds().width/2.f,
mainWindow.getSize().y/2 - titleText.getGlobalBounds().height/2.f);
playText.setFont(mainFont);
playText.setString("Play!");
playText.setCharacterSize(30);
playText.setPosition(mainWindow.getSize().x/3 - playText.getGlobalBounds().width/2.f,
mainWindow.getSize().y/3 *2 - playText.getGlobalBounds().height/2.f);
quitText.setFont(mainFont);
quitText.setString("Quit.");
quitText.setCharacterSize(30);
quitText.setPosition(mainWindow.getSize().x/3 *2 - quitText.getGlobalBounds().width/2.f,
mainWindow.getSize().y/3*2-quitText.getGlobalBounds().height/2.f);
scoreText.setFont(mainFont);
scoreText.setCharacterSize(30);
scoreText.setPosition(mainWindow.getSize().x/2 - scoreText.getGlobalBounds().width/2.f,
mainWindow.getSize().y/3-scoreText.getGlobalBounds().height/2.f);
}
示例3: gameWindow
Pong() : gameWindow(sf::VideoMode(600, 480), "Pong")
{
ball.setFillColor(sf::Color::Cyan);
ball.setPosition(100.0, 100.0);
ball.setRadius(10.f);
p1Paddle.setFillColor(sf::Color::Green);
p1Paddle.setPosition(10.0, 100.0);
p1Paddle.setSize(sf::Vector2f(10.0, 100.0));
p2Paddle.setFillColor(sf::Color::Red);
p2Paddle.setPosition(580.0, 100.0);
p2Paddle.setSize(sf::Vector2f(10.0, 100.0));
p1MovingUp = false;
p1MovingDown = false;
p2MovingUp = false;
p2MovingDown = false;
ballMovement = sf::Vector2f(ballSpeed, ballSpeed);
font.loadFromFile("arial.ttf");
p1ScoreText.setPosition(150, 10);
p1ScoreText.setFont(font);
p1ScoreText.setString(std::to_string(p1Score));
p1ScoreText.setColor(sf::Color::Red);
p1ScoreText.setCharacterSize(24);
p2ScoreText.setPosition(450, 10);
p2ScoreText.setFont(font);
p2ScoreText.setString(std::to_string(p2Score));
p2ScoreText.setColor(sf::Color::Red);
p2ScoreText.setCharacterSize(24);
}
示例4: init
void WindowCreateThing::init(sf::RenderWindow &window) {
rectTitle.setSize(sf::Vector2f(window.getSize().x*0.45, window.getSize().y*0.07));
rectTitle.setPosition(sf::Vector2f(window.getSize().x/2-(rectTitle.getSize().x/2), window.getSize().x/4-(rectTitle.getSize().y/2)));
rectTitle.setFillColor(sf::Color(158, 158, 158));
rectTitle.setOutlineColor(sf::Color::Black);
rectTitle.setOutlineThickness(1.f);
rectMain.setSize(sf::Vector2f(window.getSize().x*0.45,window.getSize().y*0.45));
rectMain.setPosition(sf::Vector2f(rectTitle.getPosition().x, rectTitle.getPosition().y+rectTitle.getSize().y));
rectMain.setFillColor(sf::Color::White);
rectMain.setOutlineColor(sf::Color::Black);
rectMain.setOutlineThickness(1.f);
load();
starting_position = sf::Mouse::getPosition(window);
textTitle.setFont(font);
textTitle.setString("CreateThings.txt");
textTitle.setCharacterSize(24);
textTitle.setColor(sf::Color::White);
textTitle.setPosition(sf::Vector2f(rectTitle.getPosition().x+rectTitle.getSize().x*0.3, rectTitle.getPosition().y+rectTitle.getSize().y*0.1));
//textTitle.setPosition(sf::Vector2f(400,10));
textClose.setFont(font);
textClose.setString("X");
textClose.setStyle(sf::Text::Bold);
textClose.setCharacterSize(35);
textClose.setColor(sf::Color::White);
textClose.setPosition(sf::Vector2f(rectTitle.getPosition().x+rectTitle.getSize().x-30, rectTitle.getPosition().y+rectTitle.getSize().y*0.05));
///// FOLDER ICONE
textureFolder.setSmooth(true);
spriteFodler.setTexture(textureFolder);
sf::Vector2f targetSize(25.0f, 25.0f);
spriteFodler.setScale(
targetSize.x / spriteFodler.getLocalBounds().width,
targetSize.y / spriteFodler.getLocalBounds().height);
spriteFodler.setPosition(sf::Vector2f(textTitle.getPosition().x-targetSize.x, textTitle.getPosition().y));
///// CLOSE ICONE
/*textureClose.setSmooth(true);
spriteClose.setTexture(textureClose);
sf::Vector2f targetSize2(window.getSize().y*0.07, window.getSize().y*0.07);
spriteClose.setScale(
targetSize2.x / spriteClose.getLocalBounds().width,
targetSize2.y / spriteClose.getLocalBounds().height);
spriteClose.setPosition(rectTitle.getPosition().x+rectTitle.getSize().x-targetSize2.x, rectTitle.getPosition().y);*/
}
示例5: startMenu
bool startMenu(sf::Text title, sf::Text anyKey, sf::Text credits, sf::RenderWindow& window)
{
// create and load texture for earth.png
sf::Texture earth;
if(!earth.loadFromFile("img/earth2.png")) cout << "Error, could not load earth.png" << endl;
sf::Sprite earthSprite;
earthSprite.setTexture(earth);
earthSprite.setPosition(WINDOW_WIDTH / 4 , WINDOW_HEIGHT / 4);
// set title color, position, size and style
title.setColor(sf::Color::Black);
title.setPosition(WINDOW_WIDTH / 5, 0);
title.setCharacterSize(50);
title.setStyle(sf::Text::Bold);
// set anyKey position and color
anyKey.setPosition(WINDOW_WIDTH / 4.5, 410);
anyKey.setColor(sf::Color::Black);
credits.setPosition(WINDOW_WIDTH / 2.6, 450);
credits.setCharacterSize(10);
credits.setColor(sf::Color::Black);
while(window.isOpen())
{
sf::Event event;
while (window.pollEvent(event)) // process events
{
// QUIT
if (event.type == sf::Event::Closed)
{
window.close(); // close the window
return false;
}
// if the user presses any key
if(event.type == sf::Event::KeyPressed || event.type == sf::Event::MouseButtonPressed)
return true;
}
window.clear(sf::Color(255, 255, 235, 0));
window.draw(earthSprite);
window.draw(title);
window.draw(anyKey);
window.draw(credits);
window.display();
}
return false;
}
示例6: init
virtual void init()
{
dt=0;
if (!standard_font.loadFromFile("fonts/Unique.ttf"))
{
// error...
}
darken = sf::RectangleShape(sf::Vector2f(800,400));
tit.setFont(standard_font);
tit.setString("Made by");
explain.setFont(standard_font);
explain.setString("Just a bored slacker");
explain.setCharacterSize(36);
explain.setPosition(260,320);
tit.setCharacterSize(24);
// dla centrowania obiektow
sf::FloatRect tempt = tit.getGlobalBounds();
tit.setOrigin(sf::Vector2f(tempt.width/2,tempt.height/2));
tit.setPosition(400,120);
if (!tex.loadFromFile("gfx/jabslogo.png"))
{
std::cout<<"Fuckup"<<std::endl;
}
spr.setTexture(tex);
spr.setPosition(334,144);
timer.restart();
};
示例7: initTexts
void initTexts()
{
if (!font.loadFromFile("arial.ttf"))cout << "error";
endText.setFont(font);
endText.setString("Game Over");
endText.setCharacterSize(50);
endText.setColor(sf::Color( 156, 39, 176));
endText.setPosition(SIZE/2-100,SIZE/2-100);
scoreText.setFont(font);
scoreText.setCharacterSize(50);
scoreText.setColor(sf::Color(255,255,255));
scoreText.setPosition(SIZE/2-200,SIZE/2);
}
示例8: init
virtual void init()
{
dt=0;
if (!standard_font.loadFromFile("fonts/Unique.ttf"))
{
// error...
}
darken = sf::RectangleShape(sf::Vector2f(800,400));
tit.setFont(standard_font);
score.setFont(standard_font);
std::stringstream ss;
ss << your_score;
std::string str = ss.str();
tit.setString("Congrats! You beat the game\nIt took you:");
score.setString(str + " seconds");
tit.setCharacterSize(24);
score.setCharacterSize(24);
// dla centrowania obiektow
sf::FloatRect tempt = tit.getGlobalBounds();
sf::FloatRect tempr = score.getGlobalBounds();
tit.setOrigin(sf::Vector2f(tempt.width/2,tempt.height/2));
score.setOrigin(sf::Vector2f(tempr.width/2,tempr.height/2));
tit.setPosition(400,150);
score.setPosition(400,200);
score.setColor(sf::Color(0,127,127));
timer.restart();
};
示例9:
//Player constructor.
Player(sf::Texture& texture, sf::Texture& hpImage, int x, int y, sf::Font& font) {
mSprite.setTexture(texture);
mRect = sf::FloatRect(x, y, 120, 110); //Character x, y, width, height.
mName = "Player 1";
mTextName.setString(mName);
mTextName.setFont(font);
mTextName.setCharacterSize(30);
mTextName.setStyle(sf::Text::Bold);
mTextName.setColor(sf::Color::Red);
mHpSprite.setTexture(hpImage);
mHpSprite.setTextureRect(sf::IntRect(0, 0, 100, 10));
mSprite.setTextureRect(sf::IntRect(0, 15, 120, 110));
mSpeed = 0.1;
mMovement.x = 0;
mMovement.y = 0;
mCurrentFrame = 0;
mAnimationSpeed = 0.005;
mIsAlive = true;
mHP = 100;
mMaxHp = 100;
mMP = 100;
}
示例10: initializeText
//private function to initialize the text easier
//precondition: the Font must have opened correctly
void RoundEndScreen::initializeText(sf::Font &font, sf::Text &text, float x_position, float y_position, int size)
{
text.setFont(font);
text.setCharacterSize(size);
text.setPosition(x_position, y_position);
text.setColor(sf::Color::White);
}
示例11: Initialize
void Scoring::Initialize()
{
font.loadFromFile("./Resources/Fonts/jokerman.ttf");
points_graphics.setFont(font);
points_graphics.setCharacterSize(24);
points_graphics.setString("0");
}
示例12: pauseMenu
void pauseMenu()
{
pause.setFont(myFont);
pause.setCharacterSize(WIDTH / 16);
pause.setStyle(sf::Text::Bold);
pause.setColor(sf::Color::Black);
pause.setString("PAUSE");
pause.setOrigin(pause.getLocalBounds().width / 2, pause.getLocalBounds().height / 2);
pause.setPosition(WIDTH / 2, 3 * HEIGHT / 16);
sf::Vector2f menuRectSize(3 * WIDTH / 16, HEIGHT / 8);
for (int i = 0; i < pauseMenuRect.size(); i++)
{
pauseMenuRect[i].setSize(menuRectSize);
pauseMenuRect[i].setFillColor(grey);
pauseMenuRect[i].setOrigin(menuRectSize.x / 2, menuRectSize.y / 2);
pauseMenuRect[i].setPosition(WIDTH / 2, 6 * HEIGHT / 16 + i * (5 * HEIGHT / 32));
pauseMenuText[i].setFont(myFont);
pauseMenuText[i].setCharacterSize(2 * pause.getCharacterSize() / 5);
pauseMenuText[i].setStyle(sf::Text::Bold);
pauseMenuText[i].setColor(sf::Color::Black);
pauseMenuText[i].setString(pauseMenuCommands[i]);
pauseMenuText[i].setOrigin(pauseMenuText[i].getLocalBounds().width / 2, pauseMenuText[i].getLocalBounds().height / 2);
pauseMenuText[i].setPosition(pauseMenuRect[i].getPosition().x, pauseMenuRect[i].getPosition().y);
}
BILLIARDS.draw(pause);
for (int i = 0; i < pauseMenuRect.size(); i++)
{
BILLIARDS.draw(pauseMenuRect[i]);
BILLIARDS.draw(pauseMenuText[i]);
}
}
示例13: rysujStatystyki
void OknoPostaci::rysujStatystyki(sf::Text text)
{
float y = 330.;
float x = 10.;
text.setCharacterSize(25U);
text.setPosition(x, y);
text.setString("Imie: " + postac->imie);
okno.draw(text);
text.setPosition(x, y+=35);
text.setString("Klasa: " + postac->klasa_postaci);
okno.draw(text);
text.setPosition(x, y += 35);
text.setString("Zdrowie: " + to_string(postac->zdrowie) + " / " + to_string(postac->getMaxZdrowie()));
okno.draw(text);
text.setPosition(x, y += 35);
text.setString("Wytrzymalosc: " + to_string(postac->wytrzymalosc) + " / " + to_string(postac->getMaxWytrzymalosc()));
okno.draw(text);
text.setCharacterSize(20U);
text.setPosition(x, y += 55);
text.setString("Atak: " + to_string(postac->getAtak()));
okno.draw(text);
text.setPosition(x + 180, y);
text.setString("Obrona: " + to_string(postac->getObrona()));
okno.draw(text);
text.setPosition(x, y += 25);
text.setString("Szybkosc: " + to_string(postac->getSzybkosc()));
okno.draw(text);
text.setPosition(x + 180, y);
text.setString("Szczescie: " + to_string(postac->getSzczescie()));
okno.draw(text);
text.setPosition(x, y += 25);
text.setString("Zasieg: " + to_string(postac->getZasieg()));
okno.draw(text);
text.setPosition(x + 180, y);
text.setString("Obrazenia: " + to_string(postac->getObrazenia()));
okno.draw(text);
if (postac->klasa_postaci == "lucznik")
{
text.setPosition(x, y += 25);
text.setString("Posiadane strzaly: " + to_string(postac->strzaly));
okno.draw(text);
}
}
示例14: prepareText
void Game::prepareText(sf::Text &text, int height)
{
text.setFont(font);
text.setCharacterSize(Game::characterSize);
text.setStyle(sf::Text::Bold);
text.setColor(sf::Color::White);
text.setPosition(420, height);
}
示例15: set_text_size
void set_text_size()
{
assert(m_text_size > 0.0f);
m_text.setCharacterSize(m_text_size);
}