Game Development Reference
In-Depth Information
_menu.Render(_renderer);
_renderer.Render();
}
Run the program and the menu will be rendered under the title.
Only the input handling remains to be implemented. The gamepad will navigate
the menu with the left control stick or the keyboard. This requires some extra
logic to decide when a control stick has been flicked up or down. This logic is
shown below in the HandleInput function, which belongs to the Verti-
calMenu class. You may have to make a change to the Input class to make the
Controller member public so it's accessible from outside the Engine project.
bool _inDown ¼ false;
bool _inUp ¼ false;
int _currentFocus ¼ 0;
public void HandleInput()
{
bool controlPadDown ¼ false;
bool controlPadUp ¼ false;
float invertY ¼ _input.Controller.LeftControlStick.Y * -1;
if (invertY < -0.2)
{
// The control stick is pulled down
if (_inDown == false)
{
controlPadDown ¼ true;
_inDown ¼ true;
}
}
else
{
_inDown ¼ false;
}
if (invertY > 0.2)
{
if (_inUp == false)
{
controlPadUp ¼ true;
 
Search WWH ::




Custom Search