|
|
我??MSDN2k的"How to Draw Text"???章?,但是?我?示字型??quot;新?明?"的繁?中文?r,程序?s出???停在SpriteFont的MeasureString
以下是我的部分原始?
SpriteBatch ForegroundBatch;
SpriteFont CourierNew;
Vector2 FontPos;
float FontRotation;
protected override void LoadGraphicsContent(bool loadAllContent)
{
if (loadAllContent)
{
CourierNew = content.Load<SpriteFont>("新?明?");
ForegroundBatch = new SpriteBatch(graphics.GraphicsDevice);
}
FontPos = new Vector2(graphics.GraphicsDevice.Viewport.Width / 2,
graphics.GraphicsDevice.Viewport.Height / 2);
FontRotation = 0;
// TODO: Load any ResourceManagementMode.Manual content
}
protected override void Draw(GameTime gameTime)
{
graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
// TODO: Add your drawing code here
ForegroundBatch.Begin();
// Draw Hello World
string output = "Hello World我";
// Find the center of the string
Vector2 FontOrigin = CourierNew.MeasureString(output) / 2;
// Draw the string
ForegroundBatch.DrawString(CourierNew, output, FontPos, Color.LightGreen,
FontRotation, FontOrigin, 1.0f, SpriteEffects.None, 0.5f);
//Note: Change "CourierNew" to "current" above to enable switching
// Draw instructions
Vector2 guidepos = new Vector2(50, FontPos.Y + 100);
string guide = "Right Thumbstick: Rotate\nA, B, X Buttons: Change Font";
ForegroundBatch.DrawString(CourierNew, guide, guidepos, Color.Black);
ForegroundBatch.End();
base.Draw(gameTime);
} |
|