Time for action – creating buttons
The UIButton
class
for Tank Battles can be created as follows:
1. Add a new class file called
UIButtonArgs.cs
to theTankBattlesGame
project.2. Add the following
using
declaration at the beginning of theUIButtonArgs
class file:using Microsoft.Xna.Framework;
3. Modify the declaration of the
UIButtonArgs
class to derive it from theSystem.EventArgs
class by adding: System.EventArgs
at the end of the declaration line. The declaration should read:class UIButtonArgs : System.EventArgs
4. Add properties to the
UIButtonArgs
class as follows:#region Properties public Vector2 Location { get; private set; } public string ID { get; private set; } #endregion
5. Add a constructor to the
UIButtonArgs
class as follows:#region Constructor public UIButtonArgs(string id, Vector2 location) { ID = id; Location = location; } #endregion
6. Add another new class file, this time called
UIButton.cs
to theTankBattlesGame
project.7. Add the following
using
directives to...