GMS 2 GUI Menu and Buttons

N

Norea

Guest
Hello, I would like to ask you for advice on how to implement a menu with clickable buttons.

I can not understand if it's better to use objects, sprites drawn on GUI or both.

My idea is to create a simple grid in the center of the camera that contains several clickable and indipendent buttons.

To give you a clear and direct example I will post this picture of a game that I refer to for this question.

That's what i want to achieve (a sort of)



Thank you for you help and your time!
 

Lazzeking

Member
The simpler way that i'll implement it is via making a single object that can have variables attached to it like for example the area you are "going" to .
 

2Dcube

Member
I agree using a single object, say "objGUIButton" would work well. The drawing would happen in the GUI layer.
Then you just reuse the object for each button but give each a different sprite and different script to execute when clicked.

Now, I would not use the standard method of collision masks for detecting clicks, because the scaling and positions will be different from the GUI layer.
I'd just have all instances created at 0,0 and set their clickable area as GUI layer coordinates, then on mouse click check if you're in the instance's rectangle.
 
N

Norea

Guest
I agree using a single object, say "objGUIButton" would work well. The drawing would happen in the GUI layer.
Then you just reuse the object for each button but give each a different sprite and different script to execute when clicked.

Now, I would not use the standard method of collision masks for detecting clicks, because the scaling and positions will be different from the GUI layer.
I'd just have all instances created at 0,0 and set their clickable area as GUI layer coordinates, then on mouse click check if you're in the instance's rectangle.
Mmh, It's a good idea, I could do some tests and see if I can develop what I would like to do. Thank you for this reply!
 
N

Norea

Guest
I found out how to do what I wanted thanks to your tips. As soon as I've finished, I will show you the solution so that this question can also be helpful for others.
Thank you!
 
Top