I don't see anything wrong with that code, but are u calling getScore before draw?
I would call the SetPosition function inside draw so that the position is set to the correct place before drawing. If getScore isn't called before draw then the position will be wrong.
Also this line doesn't do much:scoreText.Move(0.f,0.f);
I don't know what could be causing your problem, but try debugging (maybe you already tried those things):
- You should only see one 0 instead of a whole list of them, so is pScore still correct in the getScore function or does it already contain all those 0's?
- You are drawing scoreText together with scoreB, so if the text is drawn multiple times then the background would be drawn multiple times too. (I guess you would have noticed this so the problem does not lie with calling the draw function multiple times)
- You should try calling GetPosition inside the draw function and make sure that it is still (0, 320).
This has nothing to do with your problem, but you can replace the first line (which you use in your code) with the second one.
scoreB = sf::Sprite(scoreboardIMG);
scoreB.SetImage(scoreboardIMG);
.