Adding A button object


#1

Hi there
I need to add some buttons to my game, I would like my buttons to act as one.(mouse hover effect, click effect, text of button, etc…)
Is there going to a button object in the future? or maybe I can create one with creating a custom behavior on sprite? text?
Can I suggest it for future version?
Thanks


#2

Hi,

There’s currently no button object that I know of, but you can add buttons as an image with sprites and use animations for hover effects, or as text. For hover effects on text, you’ll want to use the “cursor touch is on an object” condition, both inverted and not, then do color changes or apply other text effects (i.e., shadow) in the actions.

You can check out the menu example that’s included with GD, to see how the code looks. It was made with text objects, but you can still get an idea of how to do it.

I’m not sure if it’s planned to add button objects or not since you can use existing objects to accomplish this, but the devs are open to making improvements :slight_smile:


#3

Indeed you can do this by creating your own behavior on a sprite / text.
It would be easier to have a button object. But this is not on the agenda .


#4

Ok thank you.
I’ll make my own behavior.
It will be nice to have sometime in the future objects like: button. list, text entry box…


#5

then you can share behavours :grin:


#6

I made it
Where do I share it


#7

Here :slight_smile: