Hello,
I've ran into an issue I have no idea how to resolve.
I have a scoreboard, which is made up of a RectangleShape (back) and three Texts (caption (bold, with bigger font size), names and scores (parallel to names)). The caption is supposed to be centered on top of the rectangle, with names and scores directly below it, and the back is supposed to be 200 pixels wide and exactly as tall as the sum of caption's and names' height (of course I'm going to add some indentation after I resolve this problem).
The problem is that after using the following code (well, the following code is stripped down to the essential parts), nothing besides back's position is what I imagined it to be on the y axis (positions on the x axis work fine). The behaviour caused by this code is pictured in the attachment.
// Some initialization code I skipped (loading texts and back, tested to work as intended)
back.setSize(Vector2f(200.f, names.getLocalBounds().height+caption.getLocalBounds().height));
back.setPosition(pwindow->mapPixelToCoords(Vector2i((int)(pwindow->getSize().x-back.getSize().x), 0)));
caption.setPosition(back.getPosition().x+(back.getSize().x-caption.getLocalBounds().width)/2, back.getPosition().y); //this text should start at the top of back
float y=caption.getPosition().y+caption.getLocalBounds().height;
names.setPosition(back.getPosition().x+indentH, y); //this should move names directly under caption
points.setPosition(back.getPosition().x+back.getSize().x-indentH, y); //points has origin in upper right corner, in case you were wondering
So, is there something I don't understand about the way Text behaves (particularly setPosition() and getLocalBounds())?
If this makes a difference, I haven't moved the project from SFML 2.1 yet, but according to the changelog, nothing changed in this aspect.
Thank you for your attention, hopefully the code is readable.