© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2023
B. TyersGameMaker Fundamentalshttps://doi.org/10.1007/978-1-4842-8713-2_9

9. Mouse

Ben Tyers1  
(1)
Worthing, West Sussex, UK
 
Mouse input is great for a player to interact with in your game. When done well, the player can seamlessly play your game. Mouse events can be detected using code or Mouse Events. You will use mouse interaction for such things as
  • Interacting with menu buttons.

  • Setting a target location for a player.

  • Making a gun turret point in the mouse's direction.

  • Changing weapons.

  • Showing info on mouse over.

  • Moving a gun sight around the room.

As with keypresses, there are three main button press types:
if mouse_check_button(mb_left)
{
      //do something ...

Get GameMaker Fundamentals: Learn GML Programming to Start Making Amazing Games now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.