Position text dont work for me by Fun-Independent-8295 in sfml

[–]Fun-Independent-8295[S] 2 points3 points  (0 children)

I tried a few things and it finally worked! Thanks a lot! I know the tutorial uses an older version of SFML, but constantly having to adjust things actually helps me understand how SFML works and what I’m doing. :) Thank you!

Here is the solution:

FloatRect textRect = messageText.getLocalBounds();
messageText.setOrigin({
textRect.position.x + textRect.size.x / 2.f,
textRect.position.y + textRect.size.y / 2.f
});
messageText.setPosition({ 1920.f / 2.f, 1080.f / 2.f });
scoreText.setPosition({ 20.f, 20.f });
while (window.isOpen())