Not possible with just GDScript afaik. But a workaround is not that hard.
Define a CollisionPolygon. Then in the insepctor for it, you set “Pickable” to true. This way you will get input events when you click on the shape, which you can catch with
func _input_event( Object viewport, InputEvent event, int shape_idx ):
if shape_idx == idx_of_your_shape:
_desired_action()
Great, so no need of a button node?
Syl | 2018-02-28 08:53
I advise you to have a look into creating plugins. You can create your own custom_nodes, for example a “custom_shape_button”, which will be available from add node in the editor at the end of the process. But yeah, for that case, no button is needed. But, you could put that shape under a button of course and have it’s input change the button…
Footurist | 2018-02-28 10:45
Ok, thxs, I’ll try that. Cause the collisionpolygon don’t have text nor is pickable eh.
Syl | 2018-02-28 10:56
Well, it IS pickable if you set the pickable flag to true. Remember that due to Godot’s great node system, you can easily make textures and labels children of the collision shape!
Footurist | 2018-02-28 13:17
I used a sprite for the texture of the collisionpolygon, but there’s neither text so I have to script the ‘print’ somehow? Isn’t there a node to connect that makes that, printin a text in our font choice with big leters?