Game Development Reference
In-Depth Information
_inUp ¼ true;
}
}
else
{
_inUp ¼ false;
}
if (_input.Keyboard.IsKeyPressed(Keys.Down)
|| controlPadDown)
{
OnDown();
}
else if(_input.Keyboard.IsKeyPressed(Keys.Up)
|| controlPadUp)
{
OnUp();
}
}
The HandleInput function needs to be called in the StartMenuState.
Update method. If you don't add this call then none of the input will be
detected. HandleInput detects the particular input that the vertical menu is
interested in and then calls other functions to deal with it. At the moment there
are only two functions, OnUp and OnDown ; these will change the currently
focused menu item.
private void OnUp()
{
int oldFocus ¼ _currentFocus;
_currentFocus++;
if (_currentFocus == _buttons.Count)
{
_currentFocus ¼ 0;
}
ChangeFocus(oldFocus, _currentFocus);
}
private void OnDown()
{
int oldFocus ¼ _currentFocus;
 
Search WWH ::




Custom Search