Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Panagiotis Halatsako | |
Old Version | Published before Godot 3 was released. |
I am making a simple card game in 2D and I have created my Sprites dynamically.
How can I attach a click event on them? I’ve seen that you can use Control or Area2D/RigitBody2D but is there something simpler for that?
Have you seen the TextureButton node? You can attach a texture to it for various states (normal, pressed, hover, clicked, etc.). It also has the “pressed” signal that you can wire into your custom logic.
2D||!2D | 2016-09-03 21:58
As @2D||!2D said, TextureButton
is simple clickable sprite.
volzhs | 2016-09-04 04:29
No, I haven’t seen it, thanks for the tip. I am using gdscript for the card spawn, how does the wiring occur there?
Panagiotis Halatsako | 2016-09-04 07:02
Check out this discussion and this discussion. They should give you the information you need.
You can extend the TextureButton class. Inside this class, in the _ready() function, you can connect its “pressed” signal to a function in a card manager/etc and pass the card’s name’id/etc to the the function in the card manager and treat it how you need to. That help at all?
2D||!2D | 2016-09-04 17:15