Mouse Input

Pixel Vision 8 offers access to the mouse’s position and button states. Unlike controllers or keys, this is considered a special input and displaying a cursor or pointer will have to be manually drawn to the screen.

To access the mouse’s position, you can call the MousePosition() method:

value = MousePosition()

This will return a Pointcontaining the current X and Y value for the mouse. The mouse position can not be manually changed. It’s directly tied to the native system’s mouse pointer.

In addition to getting the mouse position, you can also poll the mouse’s button state. This can be done by calling theMouseButton() method. It requires a button ID and state value.

ID

Button

0

Left

1

Right

In addition to the Button ID, you can supply a different input state similar to how the controller input works. There are two options in the InputStateenum:

Enum

Int

InputState.Down

0

InputState.Released

1

When calling the MouseButton() method and supplying InputState.Released, it returns trueif the mouse button was down in the previous frame and is up in the current frame. Just like with the Buttons enum, you can use the InputStateenum or supply an int for either state.

Finally, if you do not supply a button ID or input state, the MouseButton() method will automatically default to the left mouse button and the down input state.