示例#1
0
    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
0
	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);
	}
示例#3
0
void CustomMenu::onEvent(const sf::Event& event) {
	Component* triggered = nullptr;

	while((triggered = popEvent(event))) {
		math::u_id id = triggered->getID();

		if(id == save->getID()) {

		} else if(id == load->getID()) {

		} else if(id == random->getID()) {
			conv << (Utility::Random::getUnsignedRandom()%1001);

			name_f->setText(SentenceGenerator::getWord(SentenceGenerator::Noun) +
					SentenceGenerator::getWord(SentenceGenerator::Noun));
			age_f->setText(conv.str());

			gender->randomize();
			//palette->randomize();

			conv.str("");
		} else if(id == back->getID())
			MenuUtils::mainMenu();
		else if(id == name_f->getID())
			name.setColor(name_f->getColor());
		else if(id == age_f->getID())
			age.setColor(age_f->getColor());
		else
			std::cerr << "Auto-destruction sequence activated. Nooooo!!!" << std::endl;
	}
}
示例#4
0
文件: Menu.cpp 项目: Coguar/Field964
void _choose_color(sf::Text & text, sf::Vector2f pos, FloatRect & rect){
	if (_select_button(pos, rect)){
		text.setColor(Color::Yellow);
	}
	else {
		text.setColor(Color::Red);
	}
}
示例#5
0
文件: hud.hpp 项目: K0teu/Squares-War
 void rysuj_tekst( sf::RenderWindow & okno, sf::Color kolor, sf::String _tresc, float x, float y )
 {
     tekst.setString( _tresc );
     tekst.setColor( kolor );
     tekst.setPosition( x, y );
     okno.draw( tekst );
     tekst.setColor( sf::Color::White );
 }
示例#6
0
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);*/
}
示例#7
0
void Menupoint::update(sf::Window& window)
{
	if	(_pos.x <= sf::Mouse::getPosition(window).x &&
	   	 _pos.x + _text.getLocalBounds().width >= sf::Mouse::getPosition(window).x &&
	   	 _pos.y <= sf::Mouse::getPosition(window).y &&
	   	 _pos.y + _text.getLocalBounds().height >= sf::Mouse::getPosition(window).y)
		_text.setColor(sf::Color::Blue);
	else
		_text.setColor(sf::Color::White);
}
示例#8
0
文件: main.cpp 项目: gaocan1992/astra
    void draw_shadow_text(sf::RenderWindow& window, sf::Text& text, sf::Color color, int x, int y)
    {
        text.setColor(sf::Color::Black);
        text.setPosition(x + 5, y + 5);
        window.draw(text);

        text.setColor(color);
        text.setPosition(x, y);

        window.draw(text);
    }
示例#9
0
文件: Menu.cpp 项目: Coguar/Field964
void showMenu(Game1 & game, MenuText & menu_text, sf::Text & text, MenuImg & fon, menuBools & bools)
{

	game.window->draw(*fon.sprite);
	if (!bools.about) {
		text.setString(menu_text.new_game);
		menu_text.new_game_rect = { fon.sprite->getPosition().x - menu_text.new_game_pos.x - text.getLocalBounds().width / 2, fon.sprite->getPosition().y - menu_text.new_game_pos.y, text.getLocalBounds().width, text.getLocalBounds().height };
		_choose_color(text, game.pos, menu_text.new_game_rect);
		text.setOrigin(text.getLocalBounds().width / 2, 0);
		text.setPosition(fon.sprite->getPosition().x - menu_text.new_game_pos.x, fon.sprite->getPosition().y - menu_text.new_game_pos.y);
		game.window->draw(text);

		text.setString(menu_text.continue_game);
		menu_text.continue_game_rect = { fon.sprite->getPosition().x - menu_text.continue_game_pos.x - text.getLocalBounds().width / 2, fon.sprite->getPosition().y - menu_text.continue_game_pos.y, text.getLocalBounds().width, text.getLocalBounds().height };
		if (bools.first_play) {
			text.setColor(Color(128, 128, 128));
		}
		else {
			_choose_color(text, game.pos, menu_text.continue_game_rect);
		}
		text.setOrigin(text.getLocalBounds().width / 2, 0);
		text.setPosition(fon.sprite->getPosition().x - menu_text.continue_game_pos.x, fon.sprite->getPosition().y - menu_text.continue_game_pos.y);
		game.window->draw(text);

		text.setString(menu_text.about);
		menu_text.about_rect = { fon.sprite->getPosition().x - menu_text.about_pos.x - text.getLocalBounds().width / 2, fon.sprite->getPosition().y - menu_text.about_pos.y, text.getLocalBounds().width, text.getLocalBounds().height };
		_choose_color(text, game.pos, menu_text.about_rect);
		text.setOrigin(text.getLocalBounds().width / 2, 0);
		text.setPosition(fon.sprite->getPosition().x - menu_text.about_pos.x, fon.sprite->getPosition().y - menu_text.about_pos.y);
		game.window->draw(text);

		text.setString(menu_text.exit);
		menu_text.exit_rect = { fon.sprite->getPosition().x - menu_text.exit_pos.x - text.getLocalBounds().width / 2, fon.sprite->getPosition().y - menu_text.exit_pos.y, text.getLocalBounds().width, text.getLocalBounds().height };
		_choose_color(text, game.pos, menu_text.exit_rect);
		text.setOrigin(text.getLocalBounds().width / 2, 0);
		text.setPosition(fon.sprite->getPosition().x - menu_text.exit_pos.x, fon.sprite->getPosition().y - menu_text.exit_pos.y);
		game.window->draw(text);
	}
	else {
		text.setColor(Color::Red);
		text.setString(menu_text.about_text);
		text.setOrigin(text.getLocalBounds().width / 2, 0);
		text.setPosition(fon.sprite->getPosition().x - menu_text.about_text_pos.x, fon.sprite->getPosition().y - menu_text.about_text_pos.y);
		game.window->draw(text);

		text.setString(menu_text.back);
		menu_text.back_rect = { fon.sprite->getPosition().x - menu_text.back_pos.x - text.getLocalBounds().width / 2, fon.sprite->getPosition().y - menu_text.back_pos.y, text.getLocalBounds().width, text.getLocalBounds().height };
		_choose_color(text, game.pos, menu_text.back_rect);
		text.setOrigin(text.getLocalBounds().width / 2, 0);
		text.setPosition(fon.sprite->getPosition().x - menu_text.back_pos.x, fon.sprite->getPosition().y - menu_text.back_pos.y);
		game.window->draw(text);
	}
}
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;
}
示例#11
0
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);
}
示例#12
0
	//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;
	}
示例#13
0
 void showMsg(std::wstring msg, sf::Color foreground) {
     if ( (msg.size() * style.fontsize ) > width ) {
         msg = linebreak(msg, int(width / style.tilesize));
     }
     textbox->setString(msg);
     textbox->setColor(foreground);
 }
示例#14
0
文件: Menu.cpp 项目: Coguar/Field964
void showMission(Game1 & game, MissionText & mission_text, sf::Text & text, Hero & hero, MenuImg & fon, menuBools & bools)
{
	if (!bools.first_play) {
		switch (hero.player->quest)
		{
		case Player::quest_status::start: text.setString(mission_text.start); break;
		case Player::quest_status::find_car: text.setString(mission_text.find_car); break;
		case Player::quest_status::find_gaz: text.setString(mission_text.find_gaz); break;
		case Player::quest_status::find_busket: text.setString(mission_text.find_buscket); break;
		case Player::quest_status::find_colon: text.setString(mission_text.find_colon); break;
		case Player::quest_status::go_to_car: text.setString(mission_text.go_to_car); break;
		}
		text.setOrigin(text.getLocalBounds().width / 2, 0);
		text.setPosition(fon.sprite->getPosition().x + 220, fon.sprite->getPosition().y - 250);
		text.setColor(Color::Red);
		game.window->draw(text);
	}
	else {
		fon.hand_sprite->setPosition(fon.sprite->getPosition().x + 200, fon.sprite->getPosition().y);
		game.window->draw(*fon.hand_sprite);

	}
	game.aim_sprite->setPosition(game.pos);
	game.window->draw(*game.aim_sprite);
	game.window->display();
}
//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);
}
示例#16
0
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]);
	}
}
示例#17
0
文件: Game.cpp 项目: clavery63/tetris
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);
}
示例#18
0
文件: main.cpp 项目: bobrusha/my_game
void getText(sf::Text & txt, sf::Font & font,char* str, int x, int y, int size)
{
	txt.setFont(font); 
	txt.setString(str);
	txt.setColor(sf::Color::Black);
	txt.setPosition(x,y);
	txt.setCharacterSize(size);
}
示例#19
0
void ColorPalette::refresh(void) {
	selected.setFillColor(color);
	label.setColor(color);

	label.setString(ColorPalette::interpret(color, str));

	rgb_c.setOutlineColor(Utility::Color::getInverseColor(color));
	bw_c.setOutlineColor(Utility::Color::getInverseColor(color));
}
void MenuState::createOption(sf::Text& textOption, int order, std::string s){
	textOption.setFont(terminal); //This font is blurry need another one!
	textOption.setCharacterSize(20);
	textOption.setString(s);
	textOption.setOrigin(static_cast<int> (textOption.getLocalBounds().width / 2), static_cast<int>(textOption.getLocalBounds().height / 2));
	textOption.setPosition(static_cast<int>((window.getDefaultView().getSize().x) / 2), 130 + order*50);
	textOption.setColor(sf::Color(128,128,128));

}
示例#21
0
void MoveDraw()
{
	moves.setFont(myFont);
	moves.setCharacterSize(12);
	moves.setStyle(sf::Text::Bold);
	moves.setColor(sf::Color::Red);
	moves.setOrigin(moves.getLocalBounds().width / 2, moves.getLocalBounds().height / 2);
	moves.setPosition(WIDTH * 3 / 4, borderDepth / 2);
	bestScore.setFont(myFont);
	bestScore.setCharacterSize(12);
	bestScore.setStyle(sf::Text::Bold);
	bestScore.setColor(sf::Color::Red);
	bestScore.setOrigin(bestScore.getLocalBounds().width / 2, bestScore.getLocalBounds().height / 2);
	bestScore.setPosition(WIDTH * 1 / 4, borderDepth / 2);

	stringstream mess2;
	if (BS != 0)
		mess2 << "Best Score: " << BS;
	else
		mess2 << "Best Score: --";
	string message2 = mess2.str();
	bestScore.setString(message2);

	if ((twoPlayerGame) || (pause2P))
	{
		if (mover > 2)
			mover = 1;
		stringstream mess;
		mess << "Player " << mover << "'s turn";
		string message = mess.str();
		moves.setString(message);
		BILLIARDS.draw(moves);
	}
	else
	{
		stringstream mess;
		mess << "Moves: " << mover;
		string message = mess.str();
		moves.setString(message);
		BILLIARDS.draw(bestScore);
		if ((onePlayerGame)||(pause1P))
			BILLIARDS.draw(moves);
	}
}
示例#22
0
//will update the string of the text if needed and color and will keep the text centered if specified
void FontManager::UpdateText(sf::Text& text, const char* txt, sf::Color color, bool setOrigin)
{
	if (txt != NULL)
		text.setString(txt);

	if (setOrigin)
		text.setOrigin(text.getGlobalBounds().width / 2.0f, text.getLocalBounds().height / 2.0f);

	text.setColor(color);
}
示例#23
0
文件: main.cpp 项目: bobrusha/my_game
void youWin (sf::Text & txt, sf::Font & font)
{
	txt.setFont(font); // font is a sf::Font

				// set the string to display
	txt.setString("You win !!!");
	txt.setColor(sf::Color::Black);
	txt.setPosition(100,100);
	txt.setCharacterSize(72);
}
示例#24
0
// This function displays text to the screen. It takes the text //
// to be displayed, the location to display it, the size of the //
// text, and the color of the text
void FontManager::SetText(sf::Text& txt, string text, int x, int y, int size, sf::Color color, bool setOrigin)
{
	txt.setFont(font);
	txt.setString(text);
	txt.setPosition(x, y);
	txt.setCharacterSize(size); 
	txt.setColor(color);

	//if (setOrigin)
		//txt.setOrigin(txt.getGlobalBounds().width / 2.0f, txt.getLocalBounds().height / 2.0f);
}
示例#25
0
void DebugScreenState::initalizeText(sf::Text& text
	, sf::Vector2f position
	, sf::String string)
{
	sf::Font& font = getContext().fonts->get(Fonts::Default);
	text.setFont(font);
	text.setCharacterSize(10);
	text.setColor(sf::Color::White);
	text.setPosition(position);
	text.setString(string);
}
示例#26
0
void GraphicEngine::transformSprite(sf::Text& sprite, const Transformation& t, const Color& color)
{
	if (t.hasPosition())
		sprite.setPosition((float)t.getX(), (float)t.getY());
	if (t.hasRotation())
		sprite.rotate(t.getRotation());
	if (color.isUsed())
		sprite.setColor(sf::Color(color.getColor()));
	if (t.hasScale())
		sprite.setScale(t.getScaleX(), t.getScaleY());
}
示例#27
0
void MenuScreen::generateGameModeButton(sf::Text& button, const string& modeName, 
	short position, const sf::Font *font,
	const sf::Vector2u& screenSize )
{
	button = sf::Text( modeName, *font );
	button.setColor( sf::Color::Blue );
	button.setStyle( sf::Text::Regular );
	sf::FloatRect textRect = button.getGlobalBounds();
	button.setOrigin( textRect.left + textRect.width / 2.0f,
		textRect.top + textRect.height / 2.0f );
	button.setPosition( screenSize.x / 2, screenSize.y * 0.2 + position * Constants::LENGTH_BUTTON_SEPERATION );
}
示例#28
0
文件: ogre_obj.hpp 项目: dvbuntu/ogre
 // Set some information about the object
 inline void set_info(int str, sf::Font *font, int size)
 {
     info_str.setString(std::to_string(str));
     info_str.setFont(*font);
     info_str.setCharacterSize(size);
     info_str.setColor(sf::Color::Black);
     health_bar_bg.setSize(sf::Vector2f(get_max_hp()/scale, 10));
     health_bar_bg.setOutlineColor(sf::Color(125,125,125));
     health_bar_bg.setOutlineThickness(1);
     health_bar_current.setSize(sf::Vector2f(str/scale, 10));
     health_bar_current.setFillColor(get_life_color(str));
 }
示例#29
0
	// Constructeur & destructeur
	Observer(const sf::Vector2f& center)
	{
		//sf::Font font;
		assert(_font.loadFromFile("vera.ttf") == true);
		_text.setColor(sf::Color::White);
		_text.setFont(_font);
		_text.setCharacterSize(50);
		_text.setStyle(sf::Text::Italic);
		_border.setPosition(center);
		_border.setOutlineColor(sf::Color::White);
		_border.setOutlineThickness(2.0);
		_border.setFillColor(sf::Color::Transparent);
	}
示例#30
0
	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();
		
		};