当前位置: 首页>>代码示例>>C++>>正文


C++ Text::getGlobalBounds方法代码示例

本文整理汇总了C++中sf::Text::getGlobalBounds方法的典型用法代码示例。如果您正苦于以下问题:C++ Text::getGlobalBounds方法的具体用法?C++ Text::getGlobalBounds怎么用?C++ Text::getGlobalBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sf::Text的用法示例。


在下文中一共展示了Text::getGlobalBounds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Draw

void Scoring::Draw(unsigned int p_num, int score)
{
	std::stringstream pointsStream;
	pointsStream << score;
	points_graphics.setString(pointsStream.str());

	switch(p_num)
	{
	case 0:
		points_graphics.setPosition(5,5);
		break;

	case 1:
		points_graphics.setPosition(WindowManager::GetSize().x - points_graphics.getGlobalBounds().width - 5,5);
		break;

	case 2:
		points_graphics.setPosition(5,WindowManager::GetSize().y - points_graphics.getGlobalBounds().height - 5);
		break;

	case 3:
		points_graphics.setPosition(WindowManager::GetSize().x - points_graphics.getGlobalBounds().width - 5,WindowManager::GetSize().y - points_graphics.getGlobalBounds().height - 5);
		break;
	}

	WindowManager::Draw(points_graphics);
}
开发者ID:vsrz,项目名称:VHH,代码行数:27,代码来源:scoring.cpp

示例2: arrange

void DropDown::arrange(sf::Text &text,sf::RectangleShape &shape)
{
	float ratiox = shape.getGlobalBounds().width/text.getGlobalBounds().width;
	float ratioy = (shape.getGlobalBounds().height/text.getGlobalBounds().height);
	ratioy*=0.5f;
	text.scale(ratiox,ratioy);
}
开发者ID:Glowny,项目名称:Korttipelimoottori,代码行数:7,代码来源:DropDown.cpp

示例3: drawNumbers

void drawNumbers(sf::RenderWindow & window,sf::Text & text, float bgHeight) {
	std::string textNum;
	sf::Vector2f position = getCenter(window);

	for (int i = 0; i < NUMBER_OF_DIGITS; i++) {
		position = polarToCartesianSys(bgHeight * 0.5f - text.getGlobalBounds().height * 2, 30.f * ( i + 1 ) - 90);
		text.setString(std::to_string( i + 1 ));
		text.setOrigin(text.getGlobalBounds().width * 0.5f, text.getGlobalBounds().height * 0.5f);
		text.setPosition(position.x + window.getSize().x * 0.5f, position.y + window.getSize().y * 0.5f);
		window.draw(text);
	}
}
开发者ID:knyazsergei,项目名称:lab7,代码行数:12,代码来源:main.cpp

示例4: 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();
		
		};
开发者ID:TarasJan,项目名称:Sleepwalker,代码行数:51,代码来源:wingame.cpp

示例5:

void		Cursor::setCursorPos(const sf::Text &text)
{
  sf::FloatRect	textSize = text.getGlobalBounds();
  sf::Vector2f	textPos = text.getPosition();

  _cursor.setPosition(textSize.width + textPos.x, textPos.y);
}
开发者ID:izissise,项目名称:PFA,代码行数:7,代码来源:Cursor.cpp

示例6: 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);
    }
开发者ID:Mischa-Alff,项目名称:TriangleSuper,代码行数:25,代码来源:Utils.hpp

示例7: UpdateText

//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);
}
开发者ID:vellucci,项目名称:Tetris-Clone,代码行数:11,代码来源:FontManager.cpp

示例8: draw

	virtual void draw(RenderWindow *window) {

		sf::RectangleShape box(window->getView().getSize());
		box.setFillColor(color);

		text.setPosition((window->getView().getSize() - Vector2f(text.getGlobalBounds().width, text.getGlobalBounds().height)) * 0.5f);

		window->draw(text);
		window->draw(box);
	}
开发者ID:mangannn,项目名称:flux,代码行数:10,代码来源:GameEnd.hpp

示例9: isTextClicked

bool isTextClicked(sf::Text text, sf::RenderWindow& window)
{
  // check if mouse is currently intersecting with text
  if(text.getGlobalBounds().intersects(sf::Rect<float> ((float)sf::Mouse::getPosition(window).x,
    (float)sf::Mouse::getPosition(window).y, 8, 8)))
  {
    return true; // if so return true, text has been clicked
  }

  else return false; // else return false, text has NOT been clicked
}
开发者ID:Joshalexjacobs,项目名称:Mikylas-Big-Country-Quiz,代码行数:11,代码来源:main.cpp

示例10: generateGameModeButton

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 );
}
开发者ID:sjbeck86,项目名称:wepwep,代码行数:12,代码来源:MenuScreen.cpp

示例11: 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();
		
		};
开发者ID:TarasJan,项目名称:Sleepwalker,代码行数:52,代码来源:jabs.cpp

示例12: 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); 
		subtit.setFont(standard_font); 


		tit.setString(title);
		subtit.setString(subtitle);

		tit.setCharacterSize(24);
		subtit.setCharacterSize(18);
		
		// dla centrowania obiektow
		
		sf::FloatRect tempt = tit.getGlobalBounds();
		sf::FloatRect temps = subtit.getGlobalBounds();
		
		tit.setOrigin(sf::Vector2f(tempt.width/2,tempt.height/2));
		subtit.setOrigin(sf::Vector2f(temps.width/2,temps.height/2));
		
		tit.setPosition(400,150);
		subtit.setPosition(400,180);
		
		timer.restart();
		
		};
开发者ID:TarasJan,项目名称:Sleepwalker,代码行数:39,代码来源:interlude.cpp

示例13: draw

void Renderer::draw(sf::Text const& text, ZIndex_t zindex, sf::RenderStates const& states)
{
    auto bounds = text.getGlobalBounds();
    if(isInScreen(bounds))
    {
        m_drawCallbacks.push_back({
            zindex,
            [&text, states] (sf::RenderTarget& renderer)
            {
                renderer.draw(text, states);
            }
        });
    }
}
开发者ID:HopsonCommunity,项目名称:ZombieGame,代码行数:14,代码来源:Renderer.cpp

示例14: trimTextToRectangleWidth

void assetHandle::trimTextToRectangleWidth(sf::Text &text, sf::RectangleShape &rect)
{

    while(true)
    {
        sf::FloatRect floatRect = text.getGlobalBounds();
        if ((floatRect.left + floatRect.width) > rect.getSize().x)
        {
            std::string newString = text.getString();
            newString = newString.substr(0, newString.size()-1);
            text.setString(newString);
        }
        else
            break;
    }
}
开发者ID:prosthetichead,项目名称:Arcadia,代码行数:16,代码来源:assetHandle.cpp

示例15: centerHonrizontally

void centerHonrizontally(sf::Text& text, unsigned int total_width)
{
  const sf::FloatRect bounds = text.getGlobalBounds();
  text.setPosition( (total_width - bounds.width) / 2, text.getPosition().y );
}
开发者ID:bdajeje,项目名称:Squares,代码行数:5,代码来源:graphics.cpp


注:本文中的sf::Text::getGlobalBounds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。