问题
I have to show my score in my game but I use 2D camera and when I move the writing "score" remains behind my player. I tried this but it doesn't function ofcr:
spriteBatch.DrawString(font, "Score: "+ score, /*param of the position */, Color.Gold);
回答1:
I don't understand your problem correctly but:
Use SpriteSortMode.BackToFront
and render your text as last item.
回答2:
From what I can tell, if you pass it a fixed Vector2 position, it should work. If not, it is not a problem related to that drawing line, but elsewhere in the code.
Perhaps an incorrect configuration of the viewport, or maybe you are 'spriteBatch.Begin'ing it incorrectly (weird transforming or the like?)
Regardless, we'll need to see some more code before we can correctly determine the problem.
来源:https://stackoverflow.com/questions/19345920/how-can-i-get-a-fixed-position-in-a-window-with-xna