tomasslavicek

MonoGame kerning problem

Feb 10th, 2014
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.75 KB | None | 0 0
  1. using Microsoft.Xna.Framework;
  2. using Microsoft.Xna.Framework.Graphics;
  3. using Microsoft.Xna.Framework.Input;
  4.  
  5. namespace GameName1
  6. {
  7.     /// <summary>
  8.     /// This is the main type for your game
  9.     /// </summary>
  10.     public class Game1 : Game
  11.     {
  12.         GraphicsDeviceManager graphics;
  13.         SpriteBatch spriteBatch;
  14.         SpriteFont tempFont;
  15.  
  16.         public Game1()
  17.             : base()
  18.         {
  19.             graphics = new GraphicsDeviceManager(this);
  20.             Content.RootDirectory = "Content";
  21.         }
  22.        
  23.         protected override void LoadContent()
  24.         {
  25.             spriteBatch = new SpriteBatch(GraphicsDevice);
  26.  
  27.             tempFont = Content.Load<SpriteFont>("SmallText");
  28.         }
  29.  
  30.         protected override void UnloadContent()
  31.         {
  32.         }
  33.  
  34.         protected override void Update(GameTime gameTime)
  35.         {
  36.             if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
  37.                 Exit();
  38.            
  39.             base.Update(gameTime);
  40.         }
  41.  
  42.         protected override void Draw(GameTime gameTime)
  43.         {
  44.             // Sample draw
  45.             graphics.GraphicsDevice.Clear(new Color(204, 204, 204));
  46.  
  47.             spriteBatch.Begin();
  48.             spriteBatch.DrawString(tempFont, "Ahoj, jak se mbm", new Vector2(20, 20), Color.Red);
  49.             spriteBatch.DrawString(tempFont, "Ahoj, jak se mb", new Vector2(20, 20), Color.Blue);
  50.             float size = tempFont.MeasureString("Ahoj, jak se mbm").X - tempFont.MeasureString("m").X;
  51.             spriteBatch.DrawString(tempFont, "m", new Vector2(20 + size, 20), Color.Yellow);
  52.             spriteBatch.End();
  53.  
  54.             base.Draw(gameTime);
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment