Time for action – updating the menu
To update the menu for Mars Runner, perform the following steps:
1. In the
MenuScreen
class file, add two new fields to theFields
region as follows:int menuTitleYPos = 80; int menuEntryYStart = 175;
2. Add a new constructor to the
MenuScreen
class, in addition to the existing constructor (located in theInitialization
region) as follows:public MenuScreen(string menuTitle, int titleYPos, int menuYPos) { this.menuTitle = menuTitle; TransitionOnTime = TimeSpan.FromSeconds(0.5); TransitionOffTime = TimeSpan.FromSeconds(0.5); menuTitleYPos = titleYPos; menuEntryYStart = menuYPos; }
3. In the
Update and Draw
region of theMenuScreen
class, modify the line of code in theUpdateMenuEntryLocations()
method that specifies the baseposition
vector, replacing175f
with our newmenuEntryYStart
variable, as follows:Vector2 position = new Vector2(0f, menuEntryYStart);
4. In the
Draw()
method, modify the line that sets thetitlePosition
vector by replacing...