GML How to add rightclick functionality?

J

JokerAlpha

Guest
Sorry if this is too much of a newbie question, first time here. I've done a few GMS2 tutorials but the game I'm working on would require someone to rightclick on a specific place (an object in the game room) and open up a gui of sorts -- like a table which provides them a list of options. Then they would be able to select one of said options to change the object itself (although I really just need help on actually spawning the GUI)

Thanks, my apologies if I'm doing something wrong.

Also: Any tutorials, notes or links to how to solve my issue would also be appreciated.
 
Last edited by a moderator:
F

Falconsoft-Industries

Guest
Did you use a global right mouse button click event? This would help... :)
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Okay, so the general click (left, middle right) events are all generated based on the collision mask of the instance and it's position in the ROOM. So, you place an instance of an object in the room, you assign it a sprite index in the object editor, and then you give it a mouse button event (in this case the right mouse pressed event). In this event you would add the code or actions that you want the instance to perform when clicked. That answers your question in general terms, but you also mention GUIs... so are you wanting the button to be on the GUI layer? If that is the case then it requires a bit of extra work...
 
J

JokerAlpha

Guest
Thanks to both of you.

Falcon - I'm not entirely sure if a global right click event is what I want -- I only want the rmb to be useful when the cursor hovers above a specific object (or multiples of that same object).

Nocturne - Thanks, I get what you're saying and I'll try and implement it immediately after I write this. Although, yeah I want the buttons to be in a sort of GUI. Like a floating table (doesn't matter where, could follow the position of the object or open up in a specific area, preferably follow position of object tho) that doesn't interact with the game world, only your clicks. I do believe this is essentially a GUI layer. I'd appreciate it if you informed me about how to make them if it's not too taxing? Although I am a very beginner so it might be out of my comprehension anyway.

Edit -- Oops, didn't mean to actually tag people. Sorry!
 

Pfap

Member
Thanks to both of you.

Falcon - I'm not entirely sure if a global right click event is what I want -- I only want the rmb to be useful when the cursor hovers above a specific object (or multiples of that same object).

Nocturne - Thanks, I get what you're saying and I'll try and implement it immediately after I write this. Although, yeah I want the buttons to be in a sort of GUI. Like a floating table (doesn't matter where, could follow the position of the object or open up in a specific area, preferably follow position of object tho) that doesn't interact with the game world, only your clicks. I do believe this is essentially a GUI layer. I'd appreciate it if you informed me about how to make them if it's not too taxing? Although I am a very beginner so it might be out of my comprehension anyway.

Edit -- Oops, didn't mean to actually tag people. Sorry!

Hello I've found that learning about how to talk about computer stuff in technical terms can be a challenge in itself. And I feel you may be using the term GUI as just a menu that you can interact with. I'm not exactly sure on the official definition of what a GUI is or what the GUI is, but in Gamemaker you can have a user interface made up of graphics on a different layer than the GUI layer which is the layer closest to the user of the device. For example if you draw a tree in your game on a layer; lets say layer 0, and then you want to draw somebody in front of the tree then you would draw the person at the same position except at depth -1. If you want to draw him behind the tree you would draw the person at a depth of 1. https://docs.yoyogames.com/source/dadiospice/002_reference/objects and instances/instances/instance properties/depth.html

Lately I've just been using normal layers and not the GUI, probably because I'm lazy and don't want to take the time to learn about the GUI layer, but also because I get good results just creating on the normal layers.

Also, it sounds like you may want the menu to move in line with some in game object so probably just normal non GUI layer stuff is what you are looking for. Maybe refer to it as a HUD? Since it's not on the GUI layer? I'm not sure if there is a standard to this type of thing.
 
Top