0 votes

I want to make an inventory for a character. When the mouse hovering over a slot with an item, its description must be shown.

in Engine by (43 points)

1 Answer

+2 votes
Best answer

You can use a TextureRect instead of a Sprite and connect it's mouse_entered- and mouse_exited-signals to show or hide the label respectively:

extends TextureRect

func ready():
    connect("mouse_entered", self, "_on_mouse_entered")
    connect("mouse_exited", self, "_on_mouse_exited")

func _on_mouse_entered():

func _on_mouse_exited():

The script above assumes that your label-node is a direct child of the TextureRect, if that's not the case you need to adapt the path to the label-node accordingly.

by (10,483 points)
selected by

How to make a label attached to a mouse?

Attach the following script to your Label:

extends Label

func _process(_delta):
    rect_position = get_global_mouse_position()

can you answer is there a command that changes the text on the label?

I just did on your other question over here.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.