Time for action – creating the UI
To create the user interface for our game, perform the following steps:
1. Add the following declaration to the declarations area of the
TankBattlesGame
class as follows:Dictionary<string, UIWidget> uiElements = new Dictionary<string, UIWidget>();
2. Create a new region in the
TankBattlesGame
to hold UI-related code as follows:#region User Interface #endregion
3. In the new
User Interface
region, add a shell for a callback method for handling button-click events as follows:void UIButton_Clicked(object sender, UIButtonArgs e) { }
4. Still inside the
User Interface
region, add theCreateUIElements()
method as follows:public void CreateUIElements() { uiElements.Add("p1Up", UIHelper.CreateButton("p1Up", "U", 60, 10)); uiElements.Add("p1Down", UIHelper.CreateButton("p1Down", "D", 60, 65)); uiElements.Add("p1Left", UIHelper.CreateButton("p1Left", "L", 5, 35)); uiElements.Add("p1Right", UIHelper.CreateButton("p1Right",...