Hi, so i have this Mario-like game...
main loop looks like
View view;
while(window.isOpen())
{
marioData.updatePlayer(View & view);
gameData.updateScore(View & view);
}
Please note that score and player are in different classes...
updatePlayer(View & view) just moves player left/right, depends on button pressed, and as the player moves, the view moves aswell - hence the view reference
updateScore(View & view) does this...
score_string.setPosition(700 + (view.getCenter().x - WIDTH/2 ) , 5);
where 700 and 5 are the on screen coords, but as the view moves, it has to move aswell in order to stay in the same place, that's when view.getCenter().x - WIDTH/2 comes into play , calculating x coord of view - screen width/2.
and my problem with this is that when i press the Left/Right button, the player, view and score moves, but score jumps like 10 pixels left/right, depends on the key pressed and stays 10pixels more left/tight than it should be, until the key is released and neither left and right key is pressed then it stays at correct position.
Please, I'm lost with this, what have I done wrong? Or is there a better way to make Score have absolute position on screen? Thanks in advance.