Game Development Reference
In-Depth Information
ButtonR3 = new ControllerButton(_joystick, 9);
}
The buttons all need to update their state.
public void Update()
{
LeftControlStick.Update();
RightControlStick.Update();
ButtonA.Update();
ButtonB.Update();
ButtonX.Update();
ButtonY.Update();
ButtonLB.Update();
ButtonRB.Update();
ButtonBack.Update();
ButtonStart.Update();
ButtonL3.Update();
ButtonR3.Update();
}
To represent these buttons on screen we need a new function in the test state.
private void DrawButtonPoint(bool held, int yPos)
{
if (held)
{
Gl.glColor3f(0, 1, 0);
}
else
{
Gl.glColor3f(0, 0, 0);
}
Gl.glVertex2f(-400, yPos);
}
This function makes it easy for all the buttons to be rendered, the color changing
as they're pressed. The function calls can go in the test state Render function
just under where the control stick axes are rendered but still before the
Gl.glEnd(); statement.
DrawButtonPoint(_controller.ButtonA.Held, 300);
DrawButtonPoint(_controller.ButtonB.Held, 280);
 
Search WWH ::




Custom Search