Home | Customize | Blog | Extras | Log In | Info
Manual | D&D icons | GML Parser | Archive | Iso City
Username: Password:  
About | Features | Directory | Banners | Contact

Designing Games with GameMaker
Designing Games with GameMaker

The mouse

For mouse interaction, the following variables and functions exist:

mouse_x* X-coordinate of the mouse in the room. Cannot be changed.
mouse_y* Y-coordinate of the mouse in the room. Cannot be changed.
mouse_button Currently pressed mouse button. As value use mb_none, mb_any, mb_left, mb_middle, or mb_right.
mouse_lastbutton Last pressed mouse button.

To check whether a particular mouse button is pressed you can use the following functions. This is in particular useful when multiple keys are pressed simultaneously.

mouse_check_button(numb) Returns whether the mouse button is currently down (use as values mb_none, mb_left, mb_middle, or mb_right).
mouse_check_button_pressed(numb) Returns whether the mouse button was pressed since the last step.
mouse_check_button_released(numb) Returns whether the mouse button was released since the last step.

The following functions can be used to check whether the mouse wheel was used.

mouse_wheel_up() Returns whether the mouse wheel was moved up since the last step.
mouse_wheel_down() Returns whether the mouse wheel was moved down since the last step.

There are some additional functions related to mouse interaction.

mouse_clear(button) Clears the state of the mouse button. This means that it will no longer generate mouse events until the player releases it and presses it again.
io_clear() Clears all keyboard and mouse states.
io_handle() Handle user io, updating keyboard and mouse status.
mouse_wait() Waits till the user presses a mouse button
.

You can change the way the mouse cursor looks like. You can choose any sprite for this. To this end you can use the following variable:

cursor_sprite Indicates the sprite that is used to represent the cursor (default no sprite is used, represented by a value of -1). You can assign one of the sprites to this variable to have it been drawn automatically at the position of the mouse cursor. (You can also switch off the windows mouse cursor in the Global Game Settings.)

Search Search


Alternative versions Alternative versions

You can also read this manual on one single long page (± 1.5 mb)

Also available in: Dutch French German

ZIP Download helpfile

Advertisement Advertisement

GameMaker Manual