Game Development Reference
In-Depth Information
up event detects when it's released again. These events are pretty straightforward,
and they toggle the held flags for each button. The third event detects when the
mouse leaves the control. This is important because once the mouse button
leaves, no more events will be reported. This means the user could click down
inside the control, leave the control, and release the mouse button. The release
event would never be passed on and the held flags would get out of sync with the
actual state of the mouse. For this reason, if the mouse leaves the control's area,
then all the held flags are set to false.
The mouse input can be tested by creating a new game state— MouseTest-
State— and loading it as the default game state in the EngineTest project.
class MouseTestState : IGameObject
{
Input _input;
bool _leftToggle = false;
bool _rightToggle = false;
bool _middleToggle = false;
public MouseTestState(Input input)
{
_input = input;
}
private void DrawButtonPoint(bool held, int yPos)
{
if (held)
{
Gl.glColor3f(0, 1, 0);
}
else
{
Gl.glColor3f(0, 0, 0);
}
Gl.glVertex2f(-400, yPos);
}
public void Render()
{
Search WWH ::




Custom Search