来自Mricrosoft XNA教育目录的片段:
/// <summary>
/// Draws the control, using SpriteBatch and SpriteFont.
/// </summary>
protected override void Draw()
{
const string message = "Hello, World!\n" +
"\n" +
"I'm an XNA Framework GraphicsDevice,\n" +
"running inside a WinForms application.\n" +
"\n" +
"This text is drawn using SpriteBatch,\n" +
"with a SpriteFont that was loaded\n" +
"through the ContentManager.\n" +
"\n" +
"The pane to my right contains a\n" +
"spinning 3D triangle.";
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin();
spriteBatch.DrawString(font, message, new Vector2(23, 23), Color.White);
spriteBatch.End();
}
Run Code Online (Sandbox Code Playgroud)
Draw每秒调用60次.在抽奖中分配消息是否有任何性能开销?它是否像我将它移动到静态助手类一样?据我所知,成本表达式由C#编译器评估.const修饰符在这里改变了什么?
| 归档时间: |
|
| 查看次数: |
2030 次 |
| 最近记录: |