游戏开发论坛

 找回密码
 立即注册
搜索
查看: 5270|回复: 2

要如何?示繁?中文字

[复制链接]

414

主题

611

帖子

621

积分

高级会员

Rank: 4

积分
621
发表于 2007-10-16 00:30:00 | 显示全部楼层 |阅读模式
我??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);
        }

3

主题

4

帖子

8

积分

新手上路

Rank: 1

积分
8
发表于 2008-1-29 00:14:00 | 显示全部楼层

Re:要如何?示繁?中文字

目前XNA不完全支持中文```
真想打中文的话``
设置SpriteFont文件````
最后有个<start><end>标记 修改里面的值```原理是UTF或者GB里面的中文代号段````

0

主题

5

帖子

9

积分

新手上路

Rank: 1

积分
9
发表于 2008-7-5 14:34:00 | 显示全部楼层

Re:要如何?示繁?中文字


目前XNA不完全支持中文```
真想打中文的话``
设置SpriteFont文件````
最后有个<start><end>标记 修改里面的值```原理是UTF或者GB里面的中文代号段````


这个是正确的解决方法
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2026-1-22 03:01

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表