Move mouse positon, draw vs draw gui [Game Maker | Advanced]
This advanced video tutorial shows you how to move the mouse position in GameMaker.
The idea is quite simple. You want to move the mouse to a specific point in your window. There are a few things to understand before jumping right into it. There are 2 mouse x,y position values (pairs) in GameMaker. The first one you can ready out with mouse_x/mouse_x. These are the values inside your game room and part of the regular draw event. The camera's zoom/view is being taken here into consideration. But what if you have draw Gui elements like buttons that are independent of the room/camera? These gui (graphical user interface) elements are based on true x,y coordinates on the screen like the window (image a sticker on the screen). Here you can use device_mouse_x_to_gui(0) and device_mouse_y_to_gui(0) to get the gui coordinates of the mouse position. With that knowledge equipped you can use window_mouse_set(x,y) to let the mouse jump to a point in the window and use the previous methods for getting (and using) gui elements like buttons. That's it!
Tldr: window_mouse_set(x,y), warning, use with caution! Get Gui mouse x,y device_mouse_x_to_gui(0)/device_mouse_y_to_gui(0)
π Support me and get fresh game art and game maker projects every month:
https://www.patreon.com/1upindie
Follow me on:
πΈ Instangram: https://www.instagram.com/1upindie
π¦ Twitter: https://twitter.com/1upIndie
π¬ Discord: https://discord.gg/gvr98nb
π Udemy: https://www.udemy.com/course/become-a-video-game-developer-with-gms-23/ (See youtube about page for discount)
CHAPTERS
-------------------------------------------------------------------------------------------------------
0:00 What we will do
1:04 Subscribe
1:16 Difference of draw and draw Gui
3:15 How to get the normal (draw) mouse x,y values from the room
3:59 How to get the true (draw Gui) mouse x,y values from the window
4:54 How to set/move the mouse to a position
7:03 Game shown: Alwa's Awakening