Customizing the Game Over screen - Having trouble changing font color on mouse enter

Hi all!

I’m having a blast learning Godot so far and am really enjoying Yann’s informative yet engaging teaching style. I feel like I’m picking up on how to use the engine faster than I did with Unity, and I just love the simplicity that a true 2D mode offers.

So, with my newfound confidence, I thought I’d give myself a little extra credit assignment and try adding a simple feature to the Game Over screen: changing the color of the Try Again text on mouse hover. I’ve learned how to use signals to get nodes to communicate with each other, so I figured the process wouldn’t be too hard to figure out, but for some reason, I can’t get it to work, and my Google-fu has failed to turn up a solution. You guys are my only hope!

I’ve connected a mouse_entered() signal from the TryAgain label to the GameOver control node, which should trigger whenever it detects the mouse over the label. The next step was to find out how to change the font color itself. Digging through the Godot API gave me:

add_font_override(“font color”, Color("#hexcode"))

(there are multiple ways of defining color, but I thought this was the easiest), and so that was what I put into my GameOver.gd, under the _on_TryAgain_mouse_entered premade function from the signal. That didn’t work, so I did more searching and found out about mouse filters either blocking or accepting mouse events. This is where I’m stuck.

Based on what I know, setting the mouse filter to “Stop” makes it so that the node accepts the input and prevents it from being passed down to any child nodes. “Pass” makes it accept the input but relays it down to its children (I think?). “Ignore” obviously ignores any input. I’ve tried setting TextureButton (the parent) to Pass and the TryAgain label (child) to Stop, but that did nothing. It also seemed to break the functionality of the TextureButton. Setting both to pass allowed the button to change the scene as intended, but the TryAgain label text still wasn’t changing color. I even tried connecting a signal to TextureButton, but that didn’t seem to work, either.

Do I have the code wrong somewhere? Most of the Google results I found to change text color were about a year old, so could it be that something changed between then and now? Did I miss something in the Godot docs? Or do I have my signals all wrong?? I’m at a loss and any help would be appreciated!

Thanks! :smiley:

Privacy & Terms