message.txt |
中文输入测试,日本語テストを入力する1 T. Q: \% J% f$ w % r9 i' ~4 [6 E G! ^! h |
DefaultFontProcessor.cs |
using System.IO;% ^, ^/ u" ~0 C: _4 }5 O9 m- W0 I+ r using Microsoft.Xna.Framework.Content.Pipeline;: e8 B* f/ ]5 h: K/ N. W0 q7 i5 l using Microsoft.Xna.Framework.Content.Pipeline.Graphics; using Microsoft.Xna.Framework.Content.Pipeline.Processors; 6 ]7 Y. F6 P: q; V3 G3 z& e! E1 } 0 g* B+ l" R3 R; X+ ^* c0 W. f namespace FontProcessors { [ContentProcessor]$ u. O/ {" u- M* f) X public class DefaultFontProcessor : FontDescriptionProcessor. P3 E8 T6 R* [( N { public override SpriteFontContent Process(FontDescription input, ContentProcessorContext context)2 p; C4 d1 m' j7 X* E {1 d0 d1 x9 v# J j: U3 \ //载入文件 string fullPath = Path.GetFullPath("message.txt"); context.AddDependency(fullPath);& c0 N7 q6 X. t8 m+ B8 Y" [( y string letters = File.ReadAllText(fullPath, System.Text.Encoding.UTF8);" T% s: H) F6 U& X 5 V& W) d9 N8 u! L" S //导入字符 foreach (char c in letters) { input.Characters.Add(c);% I P9 B% V; a1 ?* I& `2 } } return base.Process(input, context);8 s# g( b, y# E8 b }* k0 c) K: s9 x) ~$ b. v }8 \, ~, Y$ `( p \0 }# Z" H } |
Game1.cs |
using System; using System.Collections.Generic; using Microsoft.Xna.Framework;( r6 d8 C' F0 G using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; ?. N Y) h5 ] using Microsoft.Xna.Framework.GamerServices; using Microsoft.Xna.Framework.Graphics;9 J1 b/ I4 f" t using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Net; using Microsoft.Xna.Framework.Storage; , `( `* m# h. \) P- C! f6 h1 Q% O namespace HelloWorld {9 @( C; ^* ~/ l$ n P' l public class GameMain : Microsoft.Xna.Framework.Game { private GraphicsDeviceManager graphics; $ T1 v( Z3 _7 Q5 O3 a private SpriteBatch spriteBatch;3 N, V+ b4 d6 b5 Z4 p9 h private SpriteFont font; : {# U, \6 E/ N; l4 y+ _ public GameMain() { graphics=new GraphicsDeviceManager(this); Content.RootDirectory="Content";/ S3 b2 d! p+ y6 K8 ? } protected override void Initialize() { base.Initialize(); } & C2 B3 C$ E- k protected override void LoadContent() {; n' I- l! a3 o6 Y spriteBatch=new SpriteBatch(GraphicsDevice);$ K: F) q8 I' k- @ font=Content.Load<SpriteFont>("DefaultFont"); }; c l. z2 _6 [( _( B7 f' d : [# ]$ k# Q6 [. v% g6 } & \, s6 m& ~; U7 d) q% t protected override void UnloadContent() {( U$ Y! q& I5 l8 ^% t: K! }* I } 5 |9 B3 h9 U9 w2 O protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back==0 J+ g/ |- W- G4 G+ o2 h ButtonState.Pressed) { Exit();% M9 I3 A5 U# `# {/ |$ v$ D% b w+ P9 r( O }2 N# W2 `- ?. e6 q* b! X1 T : B/ v/ K% o! x+ P' d . Z5 g9 G7 }8 ]5 Z, o+ v base.Update(gameTime);7 G/ B& e( d! `! ^6 K! t4 P7 Z }+ k( I* N I- Y4 |- [* C1 G: J9 g8 y " @1 `7 S/ @( o) q - n/ E# w0 ^" B0 b$ w" K protected override void Draw(GameTime gameTime) {: y" c2 Q3 ~- B9 Q0 l graphics.GraphicsDevice.Clear(Color.CornflowerBlue);2 e4 g; z& n/ @, F& c ) B% o8 k3 @7 k1 n ; }. g2 F% v+ d( C( v spriteBatch.Begin(); DrawString("中文输入测试,日本語テストを入力する",50,50);$ V, Y) ^# P) }, c( C$ k% ?. A, p spriteBatch.End(); base.Draw(gameTime);6 \. C: F1 Y' e9 W: \ }. H, x( {8 S9 Y/ x 2 ?( ?2 k/ ], g / e# A2 t: L3 c6 q# _1 N/ X# h! F private void DrawString(String str,int x,int y) {% _' C, N+ w' F: `8 h/ |* d w! V, j) V3 } spriteBatch.DrawString(font,str,new Vector2(x,y),Color.White); } }* G# W5 Z! L) D: y( h H8 ^ } |
欢迎光临 冒险解谜游戏中文网 ChinaAVG (https://chinaavg.com/) | Powered by Discuz! X3.2 |