本文整理汇总了C++中sf::RectangleShape::getLocalBounds方法的典型用法代码示例。如果您正苦于以下问题:C++ RectangleShape::getLocalBounds方法的具体用法?C++ RectangleShape::getLocalBounds怎么用?C++ RectangleShape::getLocalBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::RectangleShape
的用法示例。
在下文中一共展示了RectangleShape::getLocalBounds方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: click
void click(sf::RectangleShape rectangle,sf::Sprite &sprite, bool &clicked, bool &player, sf::Texture &crossTexture, sf::Texture &circleTexture, sf::Event &event) {
if (((rectangle.getPosition().x <= event.mouseButton.x && event.mouseButton.x <= rectangle.getLocalBounds().width + rectangle.getPosition().x) &&
(rectangle.getPosition().y <= event.mouseButton.y && event.mouseButton.y <= rectangle.getLocalBounds().height + rectangle.getPosition().y)) &&
!(clicked)) {
std::cout << "You clicked on a rectangle" << std::endl;
clicked = true;
if (player) {
std::cout << "cross" << std::endl;
sprite.setTexture(crossTexture);
} else {
std::cout << "circle" << std::endl;
sprite.setTexture(circleTexture);
}
player = !player;
}
}
示例2: centerElement
void MameUIsenWindow::centerElement(sf::RectangleShape& rectangleShape)
{
sf::FloatRect fr = rectangleShape.getLocalBounds();
rectangleShape.setOrigin(fr.left + fr.width/2.0f, fr.top + fr.height/2.0f);
}
示例3: centerOrigin
void centerOrigin(sf::RectangleShape& shape)
{
sf::FloatRect bounds = shape.getLocalBounds();
shape.setOrigin(std::floor(bounds.left + bounds.width/2.f), std::floor(bounds.top + bounds.height/2.f));
}
示例4: centerTextPosition
void centerTextPosition( const sf::RectangleShape& rect, sf::Text& text )
{
text.setPosition( rect.getPosition().x + ( rect.getLocalBounds().width / 2 ), rect.getPosition().y + ( rect.getLocalBounds().height / 2 ) - ( text.getCharacterSize() / 2 ) );
}