How can i get a fixed position in a window with XNA?

淺唱寂寞╮ 提交于 2019-12-11 17:34:22

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!