I have a simple menu with some button nodes in my game. I want to make it so when the button is selected/hovered, two arrow icons will appear at the ends of the text of the button. How can I achieve that?
All canvas items have methods called show() and hide() that do what their names imply. So you can call show() on the arrow icons to make them appear, and hide() to make them disappear again.
When the mouse enters and exits any control node, such as your button, the button will emit a signal - either mouse_entered or mouse_exited. You can use those signals to detect when you should show or hide the arrow icons.
i like to use set_visible(true) and set_visible(false) better.
if you want to use this or show() and hide() is based on the preferences of you and your team
Is this the effect you’re trying to achieve? If so, I’d just make it as part of the theme. That way you don’t have to manually hide / show it, worry about signals etc. The downside is that this can’t be animated… but it’s simple to set up.
(works the same if you’re using a controller like Switch Pro or something)
you could put enough margins in the left and right patches of the 9-patch button graphic to put arrows there.
then use these margins to put arrows there when you want
I’m a bit sleepy, But i wanted to ask! Was there ever a downloadable example scene around? I wanted to see how it work’s so I can use the free space for controller icon’s…
Every Control Node has _on_mouse_entered and _on_mouse_exited signals. Create an ‘Arrows’ group, a node with arrows, and then show and hide it using these signals