Sek*_*hat 12
该SpriteBatch对象有一个DrawString方法:
SpriteFont可以在您的内容项目中创建并通过content.Load加载string你想写信给屏幕 Vector2要在其中绘制文本的位置Color您希望的文本设置.例如,您的draw方法可能如下所示:
public void Draw()
{
spriteBatch.Begin();
DrawPaddles(spriteBatch);
DrawBall(spriteBatch);
// this being the line that answers your question
spriteBatch.DrawString(scoreFont, playerScore.ToString(), new Vector2(10, 10), Color.White);
spriteBatch.End();
}
Run Code Online (Sandbox Code Playgroud)
请参阅http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritebatch.drawstring.aspx