I'm new here, I've learned SFML for 3 days, and got a problem @@.
I really don't know how to set position of sf::Text to the center of sf::CircleShape, have a look at the code below:
#include <SFML/Graphics.hpp>
#include <iostream>
int main(void)
{
sf::RenderWindow window(sf::VideoMode(800,600),"Object");
window.setFramerateLimit(60);
sf::Font font;
if (!font.loadFromFile("arial.ttf")) std::cout << "Couldn't load font file!" << std::endl;
sf::Text text;
text.setFont(font);
text.setPosition(10,10);
text.setColor(sf::Color::Red);
text.setString("A");
text.setCharacterSize(100);
sf::CircleShape circle;
circle.setFillColor(sf::Color::White);
circle.setPosition(10,10);
circle.setRadius(100);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed || sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)) window.close();
}
window.clear(sf::Color::Black);
window.draw(circle);
window.draw(text);
window.display();
}
}
Well, the text has only 1 char and has big size ( easy to see ), I've set its position to (10,10) but it doesn't. Seem like (10,about 20 or 30). How to solve this problem ?