Time for action – creating UITextblocks
To create the
UITextblock
class, perform the following steps:
1. Add a new class file called
UITextblock.cs
to theTankBattlesGame
project.2. Add the following
using
directives at the beginning of theUITe
xtblock
class file:using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics;
3. Modify the declaration of the
UITextblock
class to derive it fromUIWidget
by adding: UIWidget
at the end of the declaration. The class declaration should be as follows:class UITextblock : UIWidget
4. Add properties to the
UITextbloc
k
class as follows:#region Properties public Vector2 TextOffset { get; set; } public SpriteFont Font { get; set; } public string Text { get; set; } public Color TextTint { get; set; } #endregion
5. Add a constructor to the
UITextbl
ock
class as follows:#region Constructor public UITextblock( string id, Vector2 position, Vector2 textOffset, SpriteFont font, string text, Color textTint) : base(id...